According to Jack Barnett R: While burning my CPU.
> 
> > 
> > Truly, I'm not trying to flood the list with stupid questions, it just comes
> > so naturally to me.
> > 
> > 1.  There must be a command out there that translates the name of a process
> > into it's PID, what is it?
> > 
> > 2.  How could I kill all processes that have a certain name?  What about
> > killing all processes with a certain pattern in their name, how could I do
> > that?
> > 
> > I'm thinking:
> > 
> > # kill | (trans_processid *pat[]tern*)
> >    ^-whatever that command is
> > 
> > Thanks in advance.
> > 
> > Dan Browning
> > Network Administrator
> > Cyclone Computer Systems
> > 
> 
> 
> 
> ps will show you the PID ofthe proccess your running, ps -aux show all the
> processes running.  man ps
> 
> you could use the killall command, If i want to kill the pppd it would be
> killall pppd
> 
> This will work for other programs as well
> 

Nobody has commented on the command 'pidof', with a simple script you can
use it to kill off a process, i myself do not like killall in a script,
scripts can do funny things sometimes.
Here is what i would use.

#!/bin/sh

# Find a pid and kill it.
# Enter details in the system log.

if [ $# -ne 2 ]; then
 echo "Too few fields used, exiting..."
fi

LOGFILE=`grep /messages /etc/syslog.conf | awk '{print $2}'`

# The above is based on a normal distribution installed /etc/syslog.conf

TIME=`date`

case "$1" in
        start)
                $2
                echo "$TIME $2 started" >>$LOGFILE
        ;;

        stop)
                PID=`pidof $2`
                kill $PID
                echo "$TIME $2 stopped" >>$LOGFILE
        ;;

        *)
                echo "Usage: pidkill start|stop program name"
                echo "$TIME $2 invalid command used." >>$LOGFILE
                exit 1
esac

exit 0

 
The above enters everything into the syslog, (messages) file.

Command syntax is;

./pidkill start pppd

It is universal so you can replace pppd with whatever program you want.

-- 
Regards Richard.
[EMAIL PROTECTED]

Reply via email to