Re: pup problem

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



> From: centos-bounces@xxxxxxxxxx [mailto:centos-bounces@xxxxxxxxxx] On
> Behalf Of MHR
> Sent: Wednesday, June 02, 2010 12:21 PM
> To: CentOS mailing list
> Subject: Re:  pup problem
> 
> 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

How about "pkill"?

pkill $cmd    # be nice
pkill -9 $cmd # be nasty
ps -fC $cmd   # see what still didn't die

--
Owen Beckley  -  owenb@xxxxxxxxxxxx


_______________________________________________
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