Archive

Posts Tagged ‘Background’

How To: Run program in background

April 28th, 2009 Fu4ny No comments

You may know that, put "&" in the end of the command will make that command run in background. But when you logout, the terminal will be killed, and your command be killed, too.

That why we need another way: using "screen". It lets you run a new screen, do some stuff, detach, and resume your work even when you logged out.

In this 'How-to, I use SSH, if you're in a local computer, it should be the same (  hope that I'm right :P )..

  1. Login to your server
  2. In the Terminal, run "screen"
  3. Do some command you like ( you can put & in the end of each command to make it run in background )
  4. Press Ctrl + A and then Ctrl + D ( It'll detach this screen and return you to your old Terminal )
  5. Logout, and your process ( your screen ) still be running.

If you want to resume to your screen ( to do more work, kill some process, or check the process log ), just

  1. Login to your server
  2. Run "screen -r"
  3. You will be resumed to your old screen.
  4. Detach it again if you still want it running.
  5. Logout

The screen program lets you run multiple program in the same time. I never try this but you can try it yourself: Press Ctrl + A, Ctrl + C will open a new prompt, use Ctrl + A to switch between each prompt.

For more detail about screen and its command, try "man screen" ( never try this, too :P )

Categories: Post Tags: , , ,