Use SSH to start a background process on a remote server, and exit session

后端 未结 4 1388
南方客
南方客 2021-02-02 07:22

I am using SSH to start a background process on a remote server. This is what I have at the moment:

ssh remote_user@server.com \"nohup process &\"

4条回答
  •  旧巷少年郎
    2021-02-02 07:57

    You could use screen to run your process on this screen, detach from screen Ctrl-a :detach and exit your current session without problem. Then you can reconnect to SSH and attach to this screen again to continue with your task or check if is finished.

    Or you can send the command to an already running screen. Your local script should look like this:

    ssh remote_user@server.com
    screen -dmS new_screen sh
    screen -S new_screen -p 0 -X stuff $'nohup process \n'
    exit    
    

    For more info see this tutorial

提交回复
热议问题