How to  put running process to background ? Want to put current process to background and keep using the same terminal to work?

There are different ways to do that, here just few of them

1. Throw the command to background when start

This command will let your command run in background, but will be killed when current session closed.

$command &

This command will continue running even the terminal session ends.

nohup <command> <args> ><filename> 2>&1 &

2. Throw the process to background after start,

Step 1, On the terminal session, run Ctrl +Z to throw the process to background, the process will be suspended in bacground

Step 2, then use bg command to resume running in background.

Step 3, disown the job from current session

 the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to  the  job  if  the shell  receives a SIGHUP.This is same as nohup.

disown -h <jobspec>

where jobspec is the job No. , use jobs to find out the job number of the running process you want to put to background.

3.Throw the running process to background after start, forcebly way

Login to the other session, kill the parent process process, make the running process orphaned, forcebly turn it to backgound.




Comments powered by CComment