Alerting

How to set up cron schedule every 5 mins everyday except between 4 am to 6am

shilpa02
New Member

Hi,
We have outage every morning between 4 am to 6am. Don't want the splunk logs to run between this time..
I tried using this .
*/5 0-4,6-23 * * *
But this might not include 11pm to 12 am

Please suggest
Thanks

Tags (1)
0 Karma
1 Solution

FrankVl
Ultra Champion

That should work fine I would say, except that you need to change the 4 to a 3: */5 0-3,6-23 * * *. See for example: http://cron.schlitt.info/index.php?cron=*%2F15+0-4%2C6-23+*+*+*&iterations=100&test=Test
Note: I changed the example on that site to 15min, to show multiple days as that site is limited to 100 iterations for the test output.

View solution in original post

0 Karma

FrankVl
Ultra Champion

That should work fine I would say, except that you need to change the 4 to a 3: */5 0-3,6-23 * * *. See for example: http://cron.schlitt.info/index.php?cron=*%2F15+0-4%2C6-23+*+*+*&iterations=100&test=Test
Note: I changed the example on that site to 15min, to show multiple days as that site is limited to 100 iterations for the test output.

0 Karma

shilpa02
New Member

Would this include 11pm to 12 am?
And can you please share the reason for 0-3 ?

0 Karma

FrankVl
Ultra Champion

I think you might be misunderstanding how cron syntax works.

*/5 0-3 does not mean every 5 minutes from 0 till 3. It means every 5 minutes for any hour matching 0, 1, 2, 3. So effectively, that is 0:00 - 3:55. Same for the 23 at the end, that means last run of the day is at 23:55.

And that is also why you should not include the 4, as that stretches it to run from 0:00 - 4:55.

0 Karma

shilpa02
New Member

Thank you so much Frank for the extended answers. This helps a lot.

0 Karma

shilpa02
New Member

Thanks Frank for the response.
Can you please share the reason for 0-3 instead of 0-4..
Also, would this include the ties between 11pm to 12 am as well ?
Appreciate your response.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...