Hi,
I want to run a Powershell script on a Windows universal forwarder according to a cron schedule. My input looks similar to this
[powershell://Test]
script = . "$SplunkHome\etc\apps\test\bin\test.ps1"
schedule = */15 * * * *
index = test
Besides running every 15 minutes as it should, I noticed that the script also runs every time when Splunk starts. Reading https://docs.splunk.com/Documentation/Splunk/latest/Admin/Inputsconf it says: "Regardless of which option you choose, the command or script always runs once when the instance starts."
I don't want that. I don't want the script to run when Splunk starts. Is there any way to disable that?
Its my understanding that this was previously raised as a bug (SPL-141385) which has now been updated in the docs to mention that it will run at startup too. (See https://community.splunk.com/t5/Getting-Data-In/Powershell-script-input-on-a-schedule/m-p/369941#M67...)
Unfortunately the only current workaround for this is to incorporate status checking in the powershell itself, this could be by checking the time since the last execution (e.g. comparison with last modified log file) or by checking that it is expected at a specific time (e.g. if you did 0,15,30,45 in cron schedule you could check its one of these times.
Its not great, but hopefully this helps!
🌟 Did this answer help you? If so, please consider:
Your feedback encourages the volunteers in this community to continue contributing