A big thank you to the respondents. More still coming in. Chris William Yudlowsky Mathew Holger Kent Perrier Dan Astroorian Stan Francis Sanjiv Bhatia Jason Shatzkam Bryan Moore David Beaudoin Thomas Knox Mark Neill Kevin Buterbaugh Kalsi Ravinder Gary Jensen The consensus seems to favor: kill -HUP `ps -ef |grep ( script name) |awk '{print $2 }'` Although also suggested were the following: -------------------------------------------- #!/bin/tcsh foreach kk (` /bin/ps -ef | grep ( script name) |awk '{print $2}'`) kill -HUP $kk end --------------------------------------------- check out the man page for pgrep / pkill. ------------------------------------------------- what you want is: ps -ef |grep ( script name) |awk '{print $2 }' |xargs kill -HUP ---------------------------------------------------------------- There are a lot of ways to do this, some that are most obvious are: 1. kill -HUP `ps -ef |grep (script name) | awk '{print $2 }'` 2. ps -ef |grep (script name) | awk '{print "kill -HUP " $2 }' | sh 3. ps -ef |grep (script name) | awk '{print $2 }' | xargs kill -HUP ------------------------------------------------------------ pid=`ps -ef |grep ( script name) |awk '{print $2 }'` kill -HUP $pid -------------------------------------- If you're on Solaris 2.8,then you can simply do a "kill -HUP `pgrep script_name`" (those are back ticks, not single quotes, BTW). --------------------------------------------- You're using kill wrong. Kill takes parameters, not input. ( Good point...jec) You want to do: #> Kill -9 `ps -ef |grep ( script name) |awk '{print $2 }'` Note that the outside quotes in that example are backquotes, and the quotes at the awk are forward, single quotes. --------------------------------------------------------------------- man xargs ---------------------------------------------------- Pretty easy, you almost had it. kill -HUP `ps -ef | grep (script name) | nawk '{print $2}'` -------------------------------------------------------------- Try this: ps -ef | grep (script name) | awk '{print $2 }' | xargs kill -HUP The xargs command usually takes care of these types of situations. ---------------------------------------------------- Try back-ticks: kill -HUP `ps -ef | grep $pat | awk '{print $2}'` To signal all processes owned by a particular user, you might prefer kill -HUP `ps -fu userid | awk '{print $2}'` You can also do it more conservatively, in two steps: pids=`ps -ef | grep $pat | awk '{print $2}'` echo $pids # to make sure the list is reasonable kill -HUP $pids However, if you're running a reasonably recent release of Solaris, "pkill" (/usr/bin/pkill) is a much easier way to do what you want--check the man pages for pkill and pgrep. (I believe these commands were introduced sometime between Solaris 2.6 and 8.) ---------------------------------------------------------------- Try | xargs kill -1 instead of the | kill -------------------------------------------- James.Coby@veritas.com Phone 651-604-3066 After Hours: Please contact VERITAS Support at the following number. 1-800-342-0652Received on Fri Apr 27 16:15:47 2001
This archive was generated by hypermail 2.1.8 : Wed Mar 23 2016 - 16:24:53 EDT