Hi guys. I'd like to know if there is a way to schedule an input script to run multiple times also if it does not end with an exit code. I explain: i have some scripts which need to wait some time...
See more...
Hi guys. I'd like to know if there is a way to schedule an input script to run multiple times also if it does not end with an exit code. I explain: i have some scripts which need to wait some time before exiting with an output and/or an exit code. At the same time, i need to rerun the same script also if the previous is still running in background. Splunk can't do this, since it monitors the ran script and wait and exit code before running the new one. Example: [script://./bin/my_script.sh]
index=blablabla
sourcetye=blablabla
source=blablabla
interval=60
... Let's say "my_script.sh" contains a simple (it's only an example), #!/bin/bash
date
sleep 90 Now, with all current methods i used, also running it with [script://./bin/my_script.sh &] Or with a launcher.sh which detaches a child process with a "bash -c 'my_script.sh &' &" or "exec my_script.sh &" the "sleep 90" prevents splunkd to rerun the script every 60 secs, since it needs 90s to exit the previous script sleep. So, in my indexed data, i'll found 2 mins data, as for the 90s sleep, 10:00 splunkd launches "my_script.sh" and waits its exit code to index data 10:01 splunkd tries to launch a new "my_script.sh", but stops it since there's a previous "sleep 90" 10:02 splunkd indexes previous 10:00 data, and reschedule a new "my_script.sh" 10:03 as 10:01 10:04 as 10:02 ... and so on... Is there a way to force a re-run, also if a previous script pid is currently still running, and have data for, 10:00 output from "my_script.sh" 10:01 output from "my_script.sh" 10:02 output from "my_script.sh" 10:03 output from "my_script.sh" ......? Thanks.