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,

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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...