« Redirect Output to Email | Main | Monitor Your Server »
November 06, 2004
Screen Command
My Windows XP suddenly crashed when I was running a long-time Linux script, then I tried to find a way to regain the lost output, but it seems not possible, during the search on Google, I found a very useful Linux command: Screen
You can open a virtual terminal with screen command, in which you can do everything like in the normal terminal, but you can detach it if you want to do other things in the main terminal and reattach it later. It even works after you quit your main terminal, for example, your Windows crashs :-).
Common screen command:
1. Start a new terminal:
# screen
2. Type CTRL+A and D to detach this new terminal
3. Reattach it:
# screen -R
If you have more than one screens, you will be reminded how to specify certain screen, it has very clear on-screen instruction.
List all screens:
# screen -list
Reattach a screen by pid:
# screen -R pid
Detailed usage:
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]
Options:
-a Force all capabilities into each window's termcap.
-A -[r|R] Adapt all windows to the new display width & height.
-c file Read configuration file instead of '.screenrc'.
-d (-r) Detach the elsewhere running screen (and reattach here).
-dmS name Start as daemon: Screen session in detached mode.
-D (-r) Detach and logout remote (and reattach here).
-D -RR Do whatever is needed to get a screen session.
-e xy Change command characters.
-f Flow control on, -fn = off, -fa = auto.
-h lines Set the size of the scrollback history buffer.
-i Interrupt output sooner when flow control is on.
-l Login mode on (update /var/run/utmp), -ln = off.
-list or -ls. Do nothing, just list our SockDir.
-L Terminal's last character can be safely updated.
-m ignore $STY variable, do create a new screen session.
-O Choose optimal output rather than exact vt100 emulation.
-p window Preselect the named window if it exists.
-q Quiet startup. Exits with non-zero return code if unsuccessful.
-r Reattach to a detached screen process.
-R Reattach if possible, otherwise start a new session.
-s shell Shell to execute rather than $SHELL.
-S sockname Name this session
-t title Set title. (window's name).
-T term Use term as $TERM for windows, rather than "screen".
-U Tell screen to use UTF-8 encoding.
-v Print "Screen version 3.09.13 (FAU) 5-Sep-02".
-wipe Do nothing, just clean up SockDir.
-x Attach to a not detached screen. (Multi display mode).
-X Execute
Category : Command & Utility
Posted by FreeBSD Newbie at November 6, 2004 05:27 AM
Comments
Just wanted to let you know that I tried Screen and it has been a godsend! Thanks
Posted by Dale Jung at January 10, 2006 06:32 AM
