> if ( ps aux | grep -i "^root.*master" ) > /dev/null
> then
> echo "then: exit code equal 0"
> exit 0
> else
> <try to run the daemon>
>
> ... when run from the command line, the echo text displays. But, when run
> from crontab every 10 minutes, the if fails, and the else clause runs.
>
> I've tried every syntax I know, but still can't get this logic to work.

It works for me, and I suspect that it's working for you, too.
well, it's really not. The crontab execution is trying to run the daemon even when the daemon shows up in "ps aux".

 However, you
may not see the results expected if you are piping the cron output through
sendmail
I'm not, and anyway the echo is after the IF condition "fails".

Also, make sure that you're running the expected shell. Check the SHELL=
line in crontab, or force the script to run via the expected shell by
running 'sh script' instead of just 'script', or tell the script what shell
to run by adding something like the following on the first line:

#!/bin/sh
already there, and /etc/crontab also contains

SHELL=/bin/sh

Although this isn't related to your problem , you might find it simpler to
use the -q option on grep instead of redirecting the output. For example,

if ( ps -aux | grep -q -i "^root.*master" ); then

instead of,
ok.

thanks
Len


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to