The are several alternatives. Here we cover nohup
and tmux
.
$ nohup long-running-command &
It logs stdout
to nohup.log
.
-
SSH into the remote machine.
-
Install
tmux
:
$ apt install tmux
- Start
tmux
:
$ tmux
-
Start the process you want inside the started
tmux
session. -
Leave/detach the
tmux
session by typingCtrl+b
and thend
. -
You can now safely log off from the remote machine, your process will keep running inside
tmux
. -
When you come back again and want to check the status of your process you can attach to your tmux session using:
$ tmux attach
If you want to have multiple sessions running side-by-side, you should name each session using Ctrl+b
and $
.
You can get a list of the currently running sessions using:
$ tmux list-sessions
or
$ tmux ls
To attach to a running session with use:
$ tmux attach-session -t <session-name>