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!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...