Once in a while I need to leave a process running for a long period of time on a Linux server I will use the screen command. Screen allow you to run a process in a session then disconnect your SSH session but leave the process running, then log back in later and check in on the process from another SSH session.
Once screen has been installed (sudo apt-get install screen on a Debian system) you can simply type screen followed by the command line for the process you want to run. So if you want to leave a network trace running you would use something like:
# screen tcpdump -ieth0 host hostname.domain.com -w ./host.cap
This would start up tcpdump and run it in a screen session.
If you only have one screen session running on a machine then to get to it you can use:
# screen -r
However if you plan on running more than one session then you may want to give the sessions names, so for example you can run :
# screen -S capture-session tcpdump -ieth0 host hostname.domain.com -w ./host.cap
Then you can access that specific session with:
# screen -r capture-session
Once you are in a session it will perform like an ordinary SSH connection. If you wish to disconnect but leave the session running you will need to press <CTRL>+a, then d.
Post a Comment