Use screen
to keep long-running tasks running after you disconnect from SSH.
# start a new screen session
screen -S mytask
# launch script
python longscript.py
Either close the ssh client window or detach from the screen session with Ctrl-a d
(control-A, then d). After reconnecting to the server later, you may reattach to the session with
screen -x mytask
screen -S [session_name]
- create new screen sessionscreen -list
- list existing screen sessionsscreen -x [session_name]
- reattach to existing screen sessionkillall screen
- kill all screen sessions
Ctrl-a d
- detach from current screen session and leave it runningCtrl-a k
- kill current screen session