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.

Tuesday, March 26, 2013

diff - /usr/sbin/ps vs /usr/ucb/ps

Difference between /usr/sbin/ps & /usr/ucb/ps command


The command that is equivalent to /usr/usb/ps -axu is "ps -aef"

/usr/ucb/ps is BSD 
/usr/sbin/ps is SVR4 


/usr/ucb/ps -www  ==as wide as possible, this over comes the 80 column restriction that is seen in normal ps -ef command.

To see which executable is being run by a process, '/usr/ucb/ps auxwww' can be used. it shows you the exact command that invoked all the processes you see via 'ps'.