On Mon, Nov 25, 2002 at 07:47:46AM +0100, Len Conrad wrote:
> >Try running 'ps' using the -w flag (wide column mode):
> >
> > if ( ps -auxw | grep -iq "^root.*master" ) ; then
> >
> >I've tested this and it works.
>
> here, too, thanks!!
One -w switches from 80 column width to 132 column width,
Okay, I was able to duplicate your problem. It is due to the output of 'ps'
being truncated to 80 columns, the default terminal size. You are likely
running a wide terminal display on your interactive session (as I do)
yep, TeraTerm on Windows, very wide display.
but cron will see the default
Oh, besides (or instead of) using the -w flag, you might also consider just
shorting the width of the output lines. Since you don't need all the
information between the user and command fields, you could just use:
if ( ps -ax -o user,command | grep -iq "^root.*master" ) ; then
Another possibilit
Okay, I was able to duplicate your problem. It is due to the output of 'ps'
being truncated to 80 columns, the default terminal size. You are likely
running a wide terminal display on your interactive session (as I do) but
cron will see the default 80 column terminal. This is the difference betwee
What does your crontab entry look like?
*/10* * * * root/usr/local/bin/watchdog.sh
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message
> I forgot to mention, "I'm blue in the face"
Sorry, didn't know what you'd already done. Thought I had to ask.
> ... but your version, or my multiple versions, have never mishaved from the
> command line, it's running from crontab that does comes out inverted.
What does your crontab entry look
Well, it was just a guess. :) I tested against my 'named' daemon, using the
code you supplied and it works fine.
same code works fine for my AV daemon, but not for the MTA daemon
What version of FreeBSD?
4.5
Are you using
the 'stock' shell?
yes
Did you look at the output from grep t
>> From: Len Conrad <[EMAIL PROTECTED]>
>> 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".
Well, it was just a guess. :) I tested against my 'named' daemon, u
> if ( ps aux | grep -i "^root.*master" ) > /dev/null
> then
> echo "then: exit code equal 0"
> exit 0
> else
>
>
> ... 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 kno
> From: Len Conrad <[EMAIL PROTECTED]>
> This snippet works fine...
>
> if ( ps aux | grep -i "^root.*master" ) > /dev/null
> then
> echo "then: exit code equal 0"
> exit 0
> else
>
>
> ... when run from the command line, the echo text displays. But, when run
> from crontab every 10 minutes,
Trying to write a little watch-dog/keep-alive script for a couple of
related daemons, an MTA and an SMTP AV scanner.
This snippet works fine...
if ( ps aux | grep -i "^root.*master" ) > /dev/null
then
echo "then: exit code equal 0"
exit 0
else
... when run from the command line, the echo text
11 matches
Mail list logo