[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What's the problem with this cron command



T o n g wrote:
Hi,
Please take a look at the following cron task:

 * * * * *	root	ps -eaf | grep -E 'cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed=' > /dev/null || logger get executed.

It bewilders me that it is not doing what I want. Here is the syslog
when it is run:

 Mar 15 13:15:02 cxmr /USR/SBIN/CRON[22779]: (root) CMD (ps -eaf | grep -E 'cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed=' > /dev/null || logger get executed.)
 Mar 15 13:15:02 cxmr /USR/SBIN/CRON[22780]: (root) CMD ...

I.e., I want to execute a cron task if I'm not burning CD/DVD. But the
actual command never get executed, even when I'm not burning CD/DVD. If I
redo the command from the command line, it is fine:
 $ (ps -eaf | grep -E 'cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed=' > /dev/null || logger get executed.)

 $ tail /var/log/syslog
 Mar 15 13:16:27 cxmr tong: get executed.

So, what is the problem?
PS. I'm sure the PATH is setup properly in my cron, so cron can find ps &
grep.

Thanks


I think you want to run something like this:

ps -eaf | grep -v grep | grep -E 'cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed=' >> /dev/null 2>&1 && logger get executed

you need to remove grep from the output or your grep will always return true and switch out the || for && .


--
8 out of 10 Owners who Expressed a Preference said Their Cats Preferred Techno.


Reply to: