Re: parsing ps -ax output and killing processes

From: Rob (rob_at_nospam.com)
Date: 02/15/05


Date: Tue, 15 Feb 2005 12:31:16 GMT


"Rob" <rob@nospam.com> wrote in message
news:lOlQd.28361$uc.27028@trnddc09...
>
> "Rob" <rob@nospam.com> wrote in message
> news:yMlQd.28360$uc.5215@trnddc09...
>> "Rob" <rob@nospam.com> wrote in message
>> news:ctlQd.28350$uc.1458@trnddc09...
>>> After the success of writing my first script yesterday (thanks guys!)
>>> I'm motivated to move on to something more complex today.
>>> How would I go about doing something like a
>>>
>>> ps -ax | grep xxxx
>>>
>>> and then killing any processes listed (except for the one running the
>>> command of course). There may not be any processes, I
>>> was thinking to detect that I could write out to a file and check the
>>> file size, but I guess that doesn't really help me if there are
>>> any processes listed. Basically I run a shutdown script which doesn't
>>> always work, then need to verify that the script did work
>>> by seeing if processes are still running and manually killing them if
>>> they arent.
>>>
>>
>> im reading the awk man pages, it looks like that's probably what
>> i should be looking at but talk about confusing :). oh, this is for
>> bash on redhat if that makes a difference.
>>
>> im playing with something along the lines of
>> awk -F: '{ print $1 }' | ps -ax | grep xxx
>>
>>
>> to at least output the process numbers, but it doesn't return me to the
>> shell and i'm not sure what to do from there anyway :)
>>
>>
> it just occured to me the above example isn't doing anything more than
> the ps -ax | grep xxx is :) :). oops!
>
>

new direction ... i just found pgrep and pkill commands :).



Relevant Pages

  • Re: Request for Comments -- shell features and documentation
    ... > As you know, I've been adding to Bash many useful features from Awk, ... > Python, Zsh, and Ksh, and other things that you probably never heard of. ... > If command substitution string begins with '..', ...
    (comp.unix.shell)
  • Re: BASH + Best method of converting fields to variables
    ... =>I'm having some trouble getting bash to get the positional fields into variables which I ... (without calling awk) ... Time flies like the wind. ... Stranger things have .0. ...
    (Fedora)
  • Re: BASH + Best method of converting fields to variables
    ... Ow Mun Heng hath decreed: ... > I'm having some trouble getting bash to get the positional fields into variables which I ... > I ended up using awk, ...
    (Fedora)
  • Re: unix command
    ... Just where did I say I was new at awk? ... bash and the performance of the bash script is good enough that I just did ... familiarity with it is a result of less use, ... that the bash script was "EASIER" for me. ...
    (comp.unix.shell)
  • Re: log parsing
    ... > Bourne shell is quite generally applicable. ... > or do you use any non-POSIX features of bash? ... Awk is still useful for one or two-liners, ...
    (comp.lang.awk)