Saturday, June 18, 2011

Detaching a process in the foreground from the shell

If you forget to use Screen Session to allow you to terminate your shell session without terminating the job that have been running in the foreground, and it is too late to do a nohup command, you may want to consider these alternatives.

You can use the shell command called disown that detach the process from theshell that started it. Here's how to do it

Step 1:
Use Ctrl + Z to suspend the running program

Step 2:
Type bg to restart it running in the background
# bg

Step 3: Get a list of jobs running in your shell
# jobs

Step 4: Detach it from the shell
# jobs %1
(Remember to put the % before the job number which in this example is 1)

No comments: