Jump to content

Toolserver:Screen: Difference between revisions

From mediawiki.org
Content deleted Content added
Revolus (talk | contribs)
m Other features: some more comfortable than man
Revolus (talk | contribs)
+always use screen
Line 27: Line 27:


For a detailed overview of screen, see the manual page [http://linux.die.net/man/1/screen '''<tt>screen(1)</tt>'''].
For a detailed overview of screen, see the manual page [http://linux.die.net/man/1/screen '''<tt>screen(1)</tt>'''].

== Always use screen on login ==

By changing your <tt>~/.bash_profile</tt> to somewhat like
<source lang="bash">
#!/bin/bash
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
exec screen -D -R
</source>
you will always reattach to the same screen session (or create a new one if there's no screen running). With <tt>CTRL+C d</tt> you will detach the screen and log out. Use <tt>CTRL+d</tt> or type <tt>exit</tt> to close a screen. With the last screen closed you will log out.

If <tt>~/.bash_profile</tt> did not exist in prior you have to make it executable: <tt>chmod +x ~/.bash_profile</tt>.


[[Category:Documentation]]
[[Category:Documentation]]

Revision as of 18:27, 6 February 2009

Template:Getting started navbox

Problem: when you log off, the programs that were running under your session quit.

Solution: run the programs under screen.

Quick-start

Log in to a terminal (for instance, use PuTTY and log in to login.toolserver.org).

Type

$ screen

at a terminal. You will get a new shell prompt. Now run your program here. (When running php scripts in the console, GET and POST variables cannot be used.) When you want to log off, type CTRL+A CTRL+D. You will see:

[screen detached]

and you're back at the old shell prompt. Now log off; your programs will continue running in screen's virtual terminal. When you want to get them back, log in again and run

$ screen -r

This will resume a detached screen. To terminate a screen, resume it with screen -r and then press CTRL+A CTRL+K, or simply exit the shell, and screen will exit automatically.

If you are running multiple sessions, CTRL+A \ will end the session.

If you don't want to accidentally close something important, you may want to use CTRL-D instead. CTRL-D is not specific to screen, it's specific more to tty. It won't work in other programs like vi.

Other features

Opening multiple windows
Type CTRL+A c. A new screen will open. You can switch between screens with CTRL+A #, where # is the screen to switch to (starting from 0). All screens under the same session are detached and reattached together.
List all open windows
Type CTRL+A w.

For a detailed overview of screen, see the manual page screen(1).

Always use screen on login

By changing your ~/.bash_profile to somewhat like

#!/bin/bash
if [ -f ~/.bashrc ]; then
        source ~/.bashrc
fi
exec screen -D -R

you will always reattach to the same screen session (or create a new one if there's no screen running). With CTRL+C d you will detach the screen and log out. Use CTRL+d or type exit to close a screen. With the last screen closed you will log out.

If ~/.bash_profile did not exist in prior you have to make it executable: chmod +x ~/.bash_profile.