Thursday, March 28, 2013

Unix Move a process to background and bring it back to foreground

It is possible to be move a process to background so that we have the prompt back for other activities and bring the process that was send background to foreground.



Use CTRL+z to suspends a process (SIGTSTP)

(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)# cp -rp lastlog lastlog.old
^Z
[1]+  Stopped                 cp -rp lastlog lastlog.old
(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)#

Use bg command to send the command to background 

(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)# bg
[1]+ cp -rp lastlog lastlog.old &
(MySolaris10:/var/adm)#

Once command completes, it returns the status of the pid

(MySolaris10:/var/adm)#
[1]+  Done                    cp -rp lastlog lastlog.old
(MySolaris10:/var/adm)#
(MySolaris10:/var/adm)#

Using fg will bring the process to foreground.

1 comment:

  1. Great site for these post and i am seeing the most of contents have useful for my Carrier.Thanks to such a useful information.Any information are commands like to share him.

    SEO Training in Chennai
    Java Training in Chennai

    ReplyDelete