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!

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Cultivate Your Career Growth with Fresh Splunk Training

Growth doesn’t just happen—it’s nurtured. Like tending a garden, developing your Splunk skills takes the right ...