Re: pup problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Jun 2, 2010 at 9:40 AM, Bowie Bailey <Bowie_Bailey@xxxxxxx> wrote:
> MHR wrote:
>> #!/bin/bash
>>
>> # A shell script to kill that annoying runaway seamonkey that won't die
>>
>> case `basename $0` in
>>         "seakill")      cmd=seamonkey;;
>>         "foxkill")      cmd=firefox;;
>>         *)                      echo "Unrecognized command."; exit 1;;
>> esac
>>
>> kill -9 `ps -ef | grep $cmd | grep -v grep | tail -1 | awk '{print $2}'`
>> ps -ef | grep $cmd | grep -v grep
>>
>> If it works, nothing is displayed.  If seamonkey/firefox is already
>> gone, it give me kill's error for not finding the process (or for a
>> missing process number because 'ps' couldn't find it, either).
>>
>
> Isn't that command line a bit complex?  Why not use ps options to get
> what you want rather than using grep, tail, and awk to pull the PID out
> of the standard output?
>
>    ps -C $cmd -o pid= | xargs kill -9
>    ps -fC $cmd
>

It's an old script I rarely use.  Yours looks better - I'm taking it.  :-)

Thanks

mhr
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux