Linux: How can I logout but keep my programs running?
Up to Table of Contents
Generally, when you exit your SSH terminal session to a Linux server, your running scripts and foreground jobs are exited as well. There is a program called screen which allows you to keep your terminal session running even after you've closed your terminal window/logged off your Windows computer, etc.
How it works
cmderr@leo:~$ screen
This creates a new terminal window (if you're just SSHing, it'll look a little bit like you cleared the screen -- it should also display some licensing text). There's no really great comparison in standard Windows, but the idea is "multiple desktops". You've just opened a new shell within your original shell.
cmderr@leo:~$ top
Simple command showing your processes running, memory allocation, etc. This will run, and take up your whole window, until you press 'q' or until you exit your terminal session by closing the Window. With screen running, it'll stay open even after you've closed the session. So...
Close your Window and log onto your Linux server again.cmderr@leo:~$ screen -ls
There is a screen on:
3653.pts-0.leo (Detached)
1 Socket in /home/staff/users/cmderr/.screen
screen -ls lists your screen sessions which are available for you to resume.
To resume a session:
cmderr@leo:~$ screen -r 3653
And you're right back at the "top" display you left running. Test it a few times before you run your week-long model and head to Hawaii. And of course, review the man pages available on the server (man screen) or online in the related articles below.
Related Articles
Online man pages for screen: http://www.hmug.org/man/1/screen.php