Calling script from daemon
I am trying to call a script from python-daemon but it doesn't work. this is what I am linking, is it correct?
I also want to pass a random argument to this script, currently I have hardcoded it
import daemon
import time
import subprocess
import os
def interval_monitoring():
print "Inside interval monitoring"
while True:
print "its working"
# os.system("XYZ.py 5416ce0eac3d94693cf7dbd8") Tried this too but not working
subprocess.Popen("XYZ.py 5416ce0eac3d94693cf7dbd8", shell=False)
time.sleep(60)
print "condition true"
def run():
print daemon.__file__
with daemon.DaemonContext():
interval_monitoring()
if __name__ == "__main__":
run()
+3
Abhilash kumar
source
to share
1 answer
If you haven't made an XYZ.py
executable and added #!/usr/bin/env python
to the top line, then you need to call it through python and not directly. So your line will look something like this:
subprocess.check_output(["python", "XYZ.py", "5416ce0eac3d94693cf7dbd8"])
0
Manuel Riel
source
to share