From owner-freebsd-questions Sat Jun 15 2:41:45 2002 Delivered-To: freebsd-questions@freebsd.org Received: from itworks.com.au (dsl-210-15-242-169.Melbourne.netspace.net.au [210.15.242.169]) by hub.freebsd.org (Postfix) with SMTP id C124637B405 for ; Sat, 15 Jun 2002 02:41:33 -0700 (PDT) Received: (qmail 19873 invoked from network); 15 Jun 2002 09:40:45 -0000 Received: from unknown (HELO bugs) (192.168.1.100) by chip.gav.itworks.com.au with SMTP; 15 Jun 2002 09:40:45 -0000 Message-ID: <0fb101c21450$624a4950$6401a8c0@bugs> From: "Gavin Cameron" To: "S H A N" Cc: References: <547866371.20020615105033@e-box.dk> <20020615090937.GA22317@singapura.singnet.com.sg> <17510246263.20020615113013@e-box.dk> Subject: Re: Re[2]: How do I make a stop script Date: Sat, 15 Jun 2002 19:38:19 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Soren, Did you read the ps and awk manpages as you were advised to? ps auxw returns the process ID in the second column... so you want to change the awk command to read awk '{print $2}' I have no idea what the debian ps command returns so YMMV. Gavin ----- Original Message ----- From: "Søren Neigaard" To: ; "S H A N" Cc: Sent: Saturday, June 15, 2002 7:30 PM Subject: Re[2]: How do I make a stop script > Saturday, June 15, 2002, 11:09:37 AM, S H A N wrote: > > SHAN> hi, > > SHAN> put the three lines in a file say killjava.sh and run it like > > SHAN> #sh -x killjava.sh > > SHAN> #!/bin/sh > SHAN> PID=`ps auxw |grep "proximus"|awk '{ print $1}'` > SHAN> kill -9 $PID > > I tried with this first: > > #!/bin/sh > PID=`ps auxw |grep "proximus"|awk '{ print $1}'` > echo $PID > > And it printed out 'root' 12 times (the number of threads my Java app > is running), so I guess that did not work :) > > /Søren > > SHAN> for explanation pls refer to > > SHAN> $man ps > SHAN> $man grep > SHAN> $man awk > SHAN> $man kill > > SHAN> rgds, > > SHAN> On Sat, Jun 15, 2002 at 10:50:33AM +0200, Søren Neigaard wrote: > >> I am in urgent need to make a stop script for a Debian machine, I have > >> asked this question on the Debian list, but this is the fastest and > >> best list I know of, and since it should be almost the same for > >> FreeBSD, I will give it a go here too. > >> > >> My Debian is running bash. > >> > >> I need to make a script that can find the PID for a Java application, > >> where the process string contains 'proximus', and 'kill -9' that > >> process. My Java process spawns quite some threads, so I need to kill > >> the main process, not one of the threads. > >> > >> How do I do this, I have no clue, and no shell programming experience, > >> so please explain it to me carefully, a complete example would just be > >> great, with some explanation so I don't have to ask again :) > >> > >> -- > >> Med venlig hilsen/Best regards, > >> Søren Neigaard mailto:neigaard@e-box.dk > >> -- > >> "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message