Dnia sob 8. czerwiec 2002 21:57, Steven J. Yellin napisał:
> Here's a sample script that checks for an adsl pid and does something
> when the "ps auxww" command doesn't produce a line with "adsl" in it:
>
> ---------------------------------------------------------------------------
>
> #!/bin/bash
> PID=`ps auxww | grep adsl | grep -v grep | awk '{print $2}'`
> if [ -z "$PID" ]; then
>    echo No adsl pid found.  Run adsl-connect.
> fi
>
> ---------------------------------------------------------------------------
>
> If the script, as modified by you, is, say, /usr/local/bin/checkadsl, it
> will run every 5 minutes with the following line in root's crontab:
>
> */5 * * * * /usr/local/bin/checkadsl
>
> For more information, do "man -a crontab".

ps auxww gives you a list of processes with its parameters. It's not what you 
want if you just grep it this way.
You want to know whether a program called adsl is running. This script checks 
whether there is running ANY program that has 'adsl' somewhere in its name, 
its arguments, even inside its user name.
You may get displayed PIDs of such commands (for example):

echo "No adsl running"
tail -f /tmp/nadslines
cp adslinfo.txt /tmp

...and many more.
Instead of
> PID=`ps auxww | grep adsl | grep -v grep | awk '{print $2}'`
you may want to use:

 PID=`/bin/ps --no-headers -C adsl -o pid`
or
 PID=`/bin/ps -e -o pid,comm | /bin/grep '\<adsl\>' | /bin/awk ' {print $1}'`

--Mariusz



_______________________________________________
Seawolf-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/seawolf-list

Reply via email to