Getting Data In

I only want a python script to run once upon first startup. How to disable a python script from running again if I restart?

arnaudhebert
Engager

Let's say I am building an app with a python script inside the bin folder.
I want my script to only run once (at the very first startup then never again).
If I restart, I don't want the script to run again. How would I go about to do that?

If I have
inputs.conf
interval = -1
this is running my script at each startup so this is not what I want.

schedule doesn't seem to be what I want either.

Should my python script update the inputs.conf from disable = false to disable = true?
that's sounds awful

0 Karma

hardikJsheth
Motivator

I agree with @Somesoni2. One other option is you collect data into particular index with specific sourcetype. Every time you run a script, first query the splunk, if you get the values that means script had already run don't run it again.

0 Karma

somesoni2
Revered Legend

Your script can check for existence of a a flag file somewhere within Splunk dir when it runs first (using interval=-1). If it's there it won't run (it won't be there first time) and it it's not run and at the end create the file so that next time it's not triggered. And if you want it to run again, simple delete the flag file and restart Splunk.

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