[WBEL-users] Another Shell Scripting Question

Vincent Raffensberger Vincent.Raffensberger at dtn.com
Wed Jun 15 15:06:11 CDT 2005


Doing this would kill the first one in the list.  By default the ps list
is sorted by pid.  
If you really want the oldest pid and not the lowest pid number, you'll
need to sort the list by start time:

kill `ps -eo pid,start,cmd --sort start | grep "[s]sh -f -N" | head -1 |
awk '{ print $1 }'`


-----Original Message-----
From: whitebox-users-bounces at beau.org
[mailto:whitebox-users-bounces at beau.org] On Behalf Of Johnny Hughes
Sent: Wednesday, June 15, 2005 2:13 PM
To: WhiteBox Users
Subject: RE: [WBEL-users] Another Shell Scripting Question

On Thu, 2005-06-16 at 02:44 +0800, Andrew Vong wrote:
> Hi Vic,
> 
> Sorry, perhaps I wasn't very clear. I don't want to kill ALL 
> processes. I only want to kill the top most process.
> 
> Is there a way to limit the std output? so that only 1 PID gets sent 
> to be killed?

One way would be to pipe your list to :

| head -n 1 |

prior to the kill command


> At 02:37 AM 16/06/2005, Vic wrote:
> > > I suppose this would work great if there were only 1 process as a 
> > > result of the cmd above.
> > >
> > > What would happen if there were more than 1 PID from std output?
> > >
> > > Will it kill ALL PIDs that were produced from std output?
> >
> >man killall
> >
> >HTH
> >
> >Vic.




More information about the Whitebox-users mailing list