start a background process with nohup using fabric

后端 未结 10 2095
广开言路
广开言路 2020-12-04 22:31

am trying to start a celerycam process using fabric using the below nohup command. Unfortunately, nothing is happening, manually using the same command i could start the pro

10条回答
  •  猫巷女王i
    2020-12-04 22:58

    As I have experimented, the solution is a combination of two factors:

    • run process as a daemon: nohup ./command &> /dev/null &
    • use pty=False for fabric run

    So, your function should look like this:

    def background_run(command):
        command = 'nohup %s &> /dev/null &' % command
        run(command, pty=False)
    

    And you can launch it with:

    execute(background_run, your_command)
    

提交回复
热议问题