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

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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...