As part of an automated test, I have a python script that needs to call two shell scripts that start two different servers that need to interact after the calling script ends. (It’s actually a jython script, but I’m not sure that matters at this point.) What can I do to ensure that the servers stay up after the python script ends?
At this point they’re called something like this:
def runcmd(str, sleep):
debug('Inside runcmd, executing: ' + str)
os.chdir("/new/dir/")
directory = os.getcwd()
print 'current dir: '+ directory
os.system(str)
t = threading.Thread(
target=runcmd,
args=( cmd, 50,)
)
Python threads will all die with Python. Also, os.system is blocking. But that’s okay — if the command that os.system() runs launches a new process (but not a child process), all will be fine. On Windows, for instance, if the command begins with “start” the “start”‘d process will remain after Python dies.
EDIT:
nohupis an equivalent tostarton Linux. (Thanks to S. Lott).