Thanks to all those that replied. The answer is: $! returns pid of last background process $$ returns current process pid. The "gotcha" i had was that my script executes more scripts to run the httpd. I couldn't capture the pid of commands in sub-scripts. I found that by obtaining the pid of the master script when started "echo $$ > /var/run/master.script.pid" (declared at begging of script) i could use this group pid to kill all processes started by the main script with: pkill -g `cat /var/run/master.script.pid` Thanks Dan. On Tue, 2005-03-29 at 20:24, Dan's generic account wrote: > Hi all > > > Is it possible to capture the PID of a command at the time of execution and > write it to a log file??? > > I need to capture the PID at the time of execution, as several instances of > the command will be run at the same time, i need to make sure that the correct > process is killed when required. > > an example would be having several instances httpd running. > > running the httpd startup script produces the following output: > ./scripts/httpd.sh 2>&1 |tee /var/log/jini.httpd.log & > [1] 1199 > bash-2.03# Mar 29, 2005 8:28:05 PM com.sun.jini.tool.ClassServer run > INFO: ClassServer started [lib/dl/, port 8082] > > > > > the 1199 is the group process, so i could just use "kill -- -1199". any child > process die. > The above pipe to tee does not report the group PID. i just get the > following: > > bash-2.03# cat /var/log/jini.httpd.log > Mar 29, 2005 8:28:05 PM com.sun.jini.tool.ClassServer run > INFO: ClassServer started [lib/dl/, port 8082] > > how can i trap the PID? > > Thanks > Dan. > > > The information contained within this e-mail and any files attached to this > e-mail is confidential and in addition may include commercially sensitive > information. The contents of this e-mail are for the intended recipient only > and therefore if you wish to disclose the information contained within this > e-mail or attached files, please contact the sender prior to any such > disclosure. > If you are not the intended recipient, any disclosure, copying or distribution > is prohibited. Please also contact the sender and inform them of the error and > delete the e-mail, including any attached files from your system. > _______________________________________________ > sunmanagers mailing list > sunmanagers@sunmanagers.org > http://www.sunmanagers.org/mailman/listinfo/sunmanagers _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagersReceived on Wed Mar 30 14:10:09 2005
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:45 EST