How to fire and forget a subprocess?

前端 未结 5 1291
深忆病人
深忆病人 2021-01-31 04:28

I have a long running process and I need it to launch another process (that will run for a good while too). I need to only start it, and then completely forget about it.

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 05:08

    i found the answers above broke my terminal and messed up the output. this is the solution i found.

       system("nohup ./test.sh &")
    

    just in case anyone has the same issue, my goal was to log into a ssh server and then keep that process running indefinitely. so test.sh is this

    #!/usr/bin/expect -f
    spawn ssh host -l admin -i cloudkey  
    expect "pass"
    send "superpass\r"
    sleep 1000000
    

提交回复
热议问题