Sometimes, when you are in shell, you need the current process but also want to run another command. Yes, you are running in GNU/screen, but you think you have enough tabs. What can you do? Use the magic!

Put it in background


Simply press Ctrl+Z. You will be back in your shell immediately. But the process has just been put in background is NOT running. You have to use bg to let it run in background. Use jobs to find its number and run bg 1, for example.

Want it back? Just run fg <num>.

Directly Run in Background


Run program &.

Detach it from Shell When exit


After put in background, run disown -a. You can also make directly nohup program &. However, it will show up in jobs, you can run disown -a to remove it.

When you logout, exit or Ctrl+D, the program won't exit.

This a re-post, originally posted on 2008-09-04 on The Tiny Bit blog.