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!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...