Alerting

How to set cron job to run last Thursday of every month at 2:00 AM

chandra61446
New Member

How to set cron job to run last Thursday of every month at 2:00 AM

Tags (1)
0 Karma

inventsekar
SplunkTrust
SplunkTrust
* * * * *, correspond to minute hour day month day-of-week.

0 2 25-31 * 4

- 2am, on the thursday between dates 25 to 31,

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
0 Karma

jkat54
SplunkTrust
SplunkTrust

0 2 25-31 * 4

Can be read as: @ 2am, On days 25-31, every month, on Thursday

Hopefully there wont be more than one Thursday between 25th and 31st... call me if so 😉

It just so happens that the current month is a great example of how the 25th might be the last Thursday.

However, this will probably fail on some months with less than 31 days. So you really need one alert for each month:

0 2 25-31 1 4 = Jan
0 2 22-28 2 4 = Feb (will not work on all leap years)
0 2 25-31 3 4 = Mar
0 2 24-30 4 4 = Apr
0 2 25-31 5 4 = May
0 2 24-30 6 4 = Jun
0 2 25-31 7 4 = Jul
0 2 25-31 8 4 = Aug
0 2 24-30 9 4 = Sep
0 2 25-31 10 4 = Oct
0 2 24-30 11 4 = Nov
0 2 25-31 12 4 = Dec

Which simplifies to this:
0 2 25-31 1,3,5,7,8,10.12 4 = Jan, Mar, May, Jul, Aug, Oct, Dec
0 2 22-28 2 4 = Feb (will not work on all leap years)
0 2 24-30 4,6,9,11 11 4 = Apr, Jun, Sep, Nov

0 Karma

s2_splunk
Splunk Employee
Splunk Employee

I believe this is not quite correct, as it will run on days 25-31 AND on Thursdays. There is no way to do that easily that I know of.

0 Karma
Get Updates on the Splunk Community!

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureThursday, March 27, 2025  |  11AM PST / 2PM EST | Register NowStep boldly ...

Splunk AppDynamics with Cisco Secure Application

Web applications unfortunately present a target rich environment for security vulnerabilities and attacks. ...