cudcv@warwick.ac.uk (Rob McMahon) (04/26/91)
In article <1991Apr24.214750.24522@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: >Because the 'c' option to grep isn't universally supported. On an A/UX (SysV >based) system: > >% ps axc >usage: ps [ -edalf ] [ -c corefile ] [ -s swapdev ] [ -n namelist ] [ -t tlist ] > [ -p plist ] [ -u ulist ] [ -g glist ] But note that `x' isn't support either, so if you can do ps ax | grep whatever | grep -v grep you can also do ps axc | grep whatever I assume there's a similar option for System V ? One case has been pointed out to me that fails: if the `whatever' is a shell script, the `ps c' will report it as `sh'. Rob -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
pd@x.co.uk (Paul Davey) (05/17/91)
In csh alias psg 'ps aux | sed -n -e "/sed -n -e /d\\ /\!$/p\\ /TIME COMMAND/p"' (change 'ps aux' to 'ps -ef' for sysV.) Converting to a ksh or sh function is left as an exercise for the reader ... To kill I use this script which I picked this up from the net some time back. #!/bin/sh # slay : kill processes by names # # Do our best to locate the PIDs to kill from the give # process names. # MYNAME=`basename $0` Ask=yes case $1 in "") echo "Usage: $MYNAME process_name ..." exit 1 ;; -n) Ask=no; shift ;; esac # change 'ps aux' to 'ps -ef' for sysV. PSAUX=`ps aux` for pname do line= PID= PID=`echo "$PSAUX" | grep -i $pname | awk '!/grep|'$MYNAME'/ {print $2}'` for pid in $PID do if [ $Ask = yes ] then line=`echo "$PSAUX" | awk '$2 == '$pid' {print}'` echo -n "Kill ($line)? " read reply case $reply in [Yy]*) kill -9 $pid ;; esac else kill -9 $pid fi done done -- Regards, pd@x.co.uk IXI Limited Paul Davey pd@ixi.uucp 62-74 Burleigh St. ...!uunet!ixi!pd Cambridge U.K. "These are interesting times" +44 223 462 131 CB1 1OJ USA: 1 800 XDESK 57