08-24-07 06:23 AM
mullin wrote:
> Let's say that have a program that will be run more than one instance
> on Solaris, how can I use "kill" command to delete them all if I'm
> using bash shell.
>
> If I run this command:
> /usr/ucb/ps -auxwww | grep app_name | cut -f1-3 -d ' '
>
> it will return something like this:
> userA: 12345
> userA: 12340
>
> where userA is the userid running the program and 2nd one is the PID.
>
> But, how can I write the sh script to kill them all?
The simplest way to modify what you've written is to do this:
/usr/ucb/ps -auxwww | grep app_name | cut -f2 -d' ' | xargs kill
However, I would avoid using /usr/ucb/ps and instead use a ps that
allows you to format the output. Then you can include (and search on)
only the fields you really want. For example:
ps -e -o pid,args | awk '/app_name/ { print $1 }' | xargs kill
- Logan
[ Post a follow-up to this message ]
|