Archive

cron schedule to run for every 5 minutes but not at 3-4PM on Saturday?

Explorer

Hi,

I need a cron Schedule which has to run at every 5 mins on all days except 3-4PM on Saturday?.

Thanks,

Tags (1)
0 Karma

SplunkTrust
SplunkTrust

You need two saved searches. One runs every 5 minutes Sunday - Friday, the other excludes those hours on Saturday

 */5 * * * 0-4,6

 */5 0-15,16-23 * * 5

Technically the second will run at 3:00pm and 4:00pm but not in between. Please let me know if hat is acceptable.

Credit to somisoni though, if you do this

*/5 0-14,16-23 * * 5

It won't run at 3pm but would run at 255pm and would also run at 4pm. So a great answer but leads us back to if you want it to run at 3pm and 4pm exactly or do you want it to stop at 255p and then resume at 4:05p?

Technically it can never run at 4pm exact because the scheduler isn't that precise. Sometimes it's off by a minute or two and also it takes time for the search to complete so I am going to go with what somisoni said as my final answer.

 Saturday Seach Cron:
 */5 0-14,16-23 * * 5

 Sunday through Friday Search Cron:
 */5 * * * 0-4,6
0 Karma

SplunkTrust
SplunkTrust

Shouldn't */5 0-14,15-23 * * 5 be */5 0-14,16-23 * * 5?

SplunkTrust
SplunkTrust

I was off but corrected, not with your exact answer. Thanks for mentioning it!

0 Karma

Splunk Employee
Splunk Employee

I don't believe you will be able to achieve this with a single cron schedule. Is this for a Splunk alert or just a search? Can you tell us more about what you are trying to achieve? May be easier to use SPL to filter the results between 3-4 on Saturday.

side note: https://crontab.guru << awesome site

0 Karma