Reporting

How to Schedule a search for every 30 seconds.

nkchaitanya
Explorer

I need to schedule a saved search for every 30 seconds, but I find the Basic one minute as the minimum schedule, which is also same in crons, please suggest is any other way to schedule for seconds.

Tags (1)

woodcock
Esteemed Legend

You cannot directly but you can run a CLI-based search on the search head so you can setup a cron job with 2 searches to run every second like this:

 * * * * * /my30SecondScript

And then inside my30SecondScript do something like this:

exec '/opt/splunk/bin/splunk search "my search string"'
sleep 30
exec '/opt/splunk/bin/splunk search "my search string"'

znaesh
Path Finder

To have perfect run intervals, a user can append ampersand (&) before every such sleep command.

0 Karma

hylam
Contributor

Is it possible to make a "sleep 30" custom splunk command? Is it possible to make 2 copies of the same saved search, and then put a sleep 30 in one of them?

0 Karma

woodcock
Esteemed Legend

Splunk has a facility to create your own splunk commands but I have never done so so I cannot speak to that. You could to the latter which is the same as my solution but removing the first line of the script code that I wrote.

0 Karma

hylam
Contributor

Where do you put the my30SecondScript?

0 Karma

woodcock
Esteemed Legend
0 Karma

hylam
Contributor

Can I use the splunk job scheduler as a "highly available cron" to run arbitrary scripts? Splunk's job scheduler picks 1 of the search heads in an SHC to run a scheduled search. Splunk's job scheduler also prevents successive long running jobs to overlap.

0 Karma

woodcock
Esteemed Legend

Exactly the plan.

miteshvohra
Contributor

AFAIK, cron does not go down to sub-minute resolutions/granularity.

0 Karma

nkchaitanya
Explorer

Thanks @miteshvohra,
Is there any way to schedule in seconds.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...