Splunk Search

Cron Schedule

uhkc777
Explorer

I need a cron schedule for following:

executes per every hour excluding from saturday 6pm to sunday 8am?

Thanks in advance,

Tags (1)
0 Karma

somesoni2
Revered Legend

It's not natively available in Splunk CRON. Your options would be

1) create 3 copies of the search,

copy1- run every hour weekday (17 * * * 1-5)
copy2- run every hour before 6pm on sat (17 0-17 * * 6)
copy3- run every hour after 8am on sun (17 8-23 * * 7)

2) Handle non-execution in the search itself using subsearch. Add a subsearch which will check the current hour and day and returns something which will ensure search will not run. E.g.

your base search [| gentimes start=-1 | eval search=case(strftime(now(),"%w")=6 AND strftime(now(),"%H")>=18,"1=2", strftime(now(),"%w")=7 AND strftime(now(),"%H")<8,"1=2", true(),"1=1" | table search ] | rest of the search...

The subsearch will return 1=2 (which will never be true) if the day and hour falls between your maintenance schedule and will return 1=1 otherwise. So your alert will run but will not execute the search fully. Please NOTE that you need to setup your alert condition appropriately.

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 ...