screen
screen is a window manager for the console.
screen stays connected
Long running process should be run within screen so a lost connection will not stop the process. The user can detach from a running screen session at any time with ctrl-a d
and the processes in that terminal will not stop. Later, run screen -ls
to see running screens (open sockets in /var/run/screen/)
There is a screen on: 15084.pts-1.sis-jpk (Detached) 1 Socket in /var/run/screen/S-jkinney9.
and then reconnect with screen -r 15084
to pick up where you left off.
The Linux Journal article is a good walkthrough of how to use screen. While the default screenrc is adequate, this one can be put into ~/.screenrc and provides some nice indicators at the bottom
# This hardstatus line will be at the bottom of the screen #hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%-%+Lw%< %=%D %M %d %c" # This hardstatus causes the gnome termnal top bar to blink "screen" # and indicates which screen is active by shifting the "-" around. blinking is very ugly. #hardstatus string '%{= kK}%-Lw%{= KW}%50>%n%f %t%{= kK}%+Lw%< %{=kG}%-= %d%M %c:%s%-' # The caption line will be displayed at the bottom of the screen within the window caption always "%?%{ Wk}%-Lw%?%{Rk}%n*%f %t%?(%u)%?%?%{Wk}%+Lw%? %{Rk}%=%c %{rk}%Y/%m/%d" # The hardstatus line will be displayed in the gnome-terminal top bar #hardstatus string "%{+b Rk}(%{-b g}$LOGNAME@%H%{+b R}) (%{-b g}%C %a%{+b R}) %{-b g} %n %t %h" # defscrollback will set the number of lines in the scrollback buffer defscrollback 1024
screen exercise Use ssh to connect to the svn machine. Start a screen session. Run the following simple script that will display the time every 5 seconds. while true; do echo -en $(date)"\r"; sleep 5s; done Detach from the screen session and log out of the svn machine. Log back in and reattach to the screen session and verify the script is still running. |