import time
import commands
from subprocess import Popen
while True:
t_ph = commands.getstatusoutput('ps -eo pid,args | grep script1.py | grep -v service | grep -v init.d | grep -v grep | cut -c1-6')
t_fb = commands.getstatusoutput('ps -eo pid,args | grep script2.py | grep -v service | grep -v init.d | grep -v grep | cut -c1-6')
if t_ph[1] == '':
r_ph = Popen(["python", "script1.py"])
if t_fb[1] == '':
r_fb = Popen(["python", "script2.py"])
time.sleep(60)
or
import time
import commands
from subprocess import Popen
r_ph = False
r_fb = False
while True:
if r_ph == False:
r_ph = Popen(["python", "script1.py"])
else:
if r_ph.poll():
r_ph = Popen(["python", "script1.py"])
if r_fb == False:
r_fb = Popen(["python", "script2.py"])
else:
if r_fb.poll():
r_fb = Popen(["python", "script2.py"])
time.sleep(60)
this could be written a bit better but it works
importthe two scripts and call the functions inside of them normally?Popen.