Sep 3, 2012

GNU screen: run interactive scripts in background

I have an old laptop at home. It's too slow to do any actual computing. So when I'm too lazy to go to my office, I have to ssh my desktop in my office. There is always a problem however, ssh may be time-out when I was running a long task. I could in principle, install a job schedule system, like pbs, condor. But I really wanna run interactive scripts or even X-windows on my desktop. The solution is gnu screen.

screen is a muliplexer. It's the shell version of "windows" (not confused with Microsoft Windows). It manages multiple shells (called screens) in background. The screens can be detached from your current shell, and will not stop even if the current shell terminates.

To start a new screen, one can either,

  • type in screen, one enter the new screen immediately;
  • <ctrl +a ctrl + c>, to create a new screen;
  • screen cmd will run the command cmd in a new screen;
To detach the shell from current prompt, one can press <ctrl + a + d>.

To resume a screen, one may,
  • type in screen -r [ID]; ID is needed if multiple shells are hidden. It will prompt of course all available screen IDs.

To manage multiple screens, see man screen

With GNU screen, I can ssh to my desktop, and use screen to run an interactive script or a program, then I detach the screen, and logout from my desktop. After sometime, I login and resume my screen to check the calculation result.;

No comments:

Post a Comment