From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,bedbbee8b27b663b X-Google-Attributes: gidfee84,public X-Google-Thread: 1020c6,bedbbee8b27b663b X-Google-Attributes: gid1020c6,public From: Mark Lambert Subject: Re: killing a process by name? Date: 1999/06/09 Message-ID: <375DBA80.76E3B5FA@fulcrum.com.au>#1/1 X-Deja-AN: 487301499 Content-Transfer-Encoding: 7bit References: <375d6a41.14695581@news.aurora.edu> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@connect.com.au X-Trace: perki.connect.com.au 928889473 14302 203.2.211.248 (9 Jun 1999 00:51:13 GMT) Organization: Fulcrum Consulting Group Mime-Version: 1.0 NNTP-Posting-Date: 9 Jun 1999 00:51:13 GMT Newsgroups: comp.unix.osf.osf1,comp.unix.admin Christopher Kolar wrote: > > Hello everyone. This is probably a basic question, but I have not > found the solution yet so I thought I would float it. I have a host > running OSF 4.0d. After everyone leaves for the day I am going to > have cron start a program "foo". Foo should run until midnight, when > it needs to be killed so that out nightly backups can happen. > Serguei Patchkovskii had a more elegant awk solution, but mine is (I think) more understandable for non-awk guru's... the brute force approach :0 try kill `ps -ef | grep foo | grep -v grep | awk '{print $2}'` that is: kill (the numbers returned from the ``comand): ps piped into a grep for foo, then discard the process running the grep command, pipe the resulting ps line(s) into awk printing only the PID field. Have fun! -- /\ The Fulcrum Consulting Group Mark Lambert - Consultant /\O\ Professional Services For Operation Mark.Lambert@fulcrum.com.au / /\ Of A Networked Computing Environment ph: +61-3-9621-2100 /o | \ 12/10-16 Queen St, Melbourne VIC 3000, Australia fx: +61-3-9621-2724