Call a python subprocess as daemon and exit

前端 未结 2 781
旧时难觅i
旧时难觅i 2021-01-04 01:23

I\'m using a pair of python programs, one of which should call the second.

But this should be done in a way that the first program makes the second one a daemon (or

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 02:04

    You can use subprocess.Popen for this:

    import subprocess
    
    cmd = ['/usr/bin/python', '/path/to/my/second/pythonscript.py']
    subprocess.Popen(cmd)
    

    You might want to redirect stdout and stderr somewhere, you can do that by passing stdout= to the Popen constructor.

提交回复
热议问题