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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...