The last modifications of this post were around 2 years ago, some information may be outdated!
Keep the running tasks on the remote host continue after turning off the local caller.
👉 Other "Shell" notes.
Install
sudo apt install screen # ubuntuBasic command lines
# check screen version
screen -v# start new session (with name)
screen -S <name># list running sessions
screen -ls# attach to a running session (without name)
screen -x# attach to a running session (with name)
screen -rx <name>
# -x for an interactive (scrolling)# detach a running session
screen -d <name> # or Ctrl + A, D# kill a session
screen -X -S <name> quitDelete sessions
- Reattach first:
screen -r <name> - Ctrl + A, K then Y
# kill ALL auto-created sesssions
screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill
# kill all detached sessions
screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs killCreate a screen + list of command lines
screen -S 'dat' -dm bash -c 'cd /jekyll-site; bundle exec jekyll serve -I; exec sh'Hotkeys
- Detach: Ctrl + A, D
- Reattach: Ctrl + A, R
- Kill current session: Ctrl + A, K then Y
Errors
# Cannot make directory '/run/screen': Permission denied
mkdir ~/.screen && chmod 700 ~/.screen
export SCREENDIR=$HOME/.screen
# also add this line to ~/.zshrc or ~/.bashrc
💬 Comments