Keep the running tasks on the remote host continue after turning off the local caller.
1sudo apt install screen # ubuntu
1# check screen version
2screen -v
1# start new session (with name)
2screen -S <name>
1# list running sessions
2screen -ls
1# attach to a running session (without name)
2screen -x
1# attach to a running session (with name)
2screen -rx <name>
3# -x for an interactive (scrolling)
1# detach a running session
2screen -d <name> # or Ctrl + A, D
1# kill a session
2screen -X -S <name> quit
- Reattach first:
screen -r <name>
Ctrl + A, K
thenY
1# kill ALL auto-created sesssions
2screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill
3
4# kill all detached sessions
5screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill
1screen -S 'dat' -dm bash -c 'cd /jekyll-site; bundle exec jekyll serve -I; exec sh'
- Detach:
Ctrl + A, D
- Reattach:
Ctrl + A, R
- Kill current session:
Ctrl + A, K
thenY
1# Cannot make directory '/run/screen': Permission denied
2mkdir ~/.screen && chmod 700 ~/.screen
3export SCREENDIR=$HOME/.screen
4# also add this line to ~/.zshrc or ~/.bashrc