we have all come crossed such situations that we need to leave for a few seconds or just some unexpected things kicked us out from the system when we were still running a program, say 'nc -l -p 80'. This happens commonly when you are logging in with a not-robust connection, and when we get back, the the program is still there, running in the background. You can see it with a 'ps -A', but never will you be able to 'fg' it.
So, what shall we do?
The answer is 'screen'. With screen, you can safely "save" a running progress in the system, and "resume" it at any time. Following is the usage from 'man screen'.
SCREEN(1) SCREEN(1)
NAME
screen - screen manager with VT100/ANSI terminal emulation
SYNOPSIS
screen [ -options ] [ cmd [ args ] ]
screen -r [[pid.]tty[.host]]
screen -r sessionowner/[[pid.]tty[.host]]
And, examples I found at a GUN/Linux CS server howto.
-d -m Start screen in "detached" mode. This creates a new session but
doesn't attach to it. This is useful for system startup
scripts.
-S sessionname
When creating a new session, this option can be used to specify a
meaningful name for the session. This name identifies the session
for "screen -list" and "screen -r" actions. It substitutes the
default [tty.host] suffix.
"save a progress in background"
'screen -A -m -d -S hlds ./hlds_run -game cstrike +ip ip.de.internet +sv_lan 1 -nomaster +maxplayers 18 +map de_dust2'
"resume it whenever necessary"
'screen -r hlds'
To make it background again, Hold ctrl, then press and hold A, then press D.
No comments:
Post a Comment