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

Re: cron and command quote



On Tue, 18 Mar 2008 03:40:35 +0100, s. keeling wrote:

>>  I.e., somehow, the 'ps | grep' was able to find something in cron, whereas
>>  when executed directly under shell:
>> 
>>   $ ps -eaf | grep -E 'cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed='
>> 
>>   $ /bin/sh -c "ps -eaf | grep -E 'cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed='"
>> 
>>  I.e., if the same command are executed directly under shell the 
>>  'ps | grep' finds nothing. 
>> 
>>  Anyone can give some explanation?
> 
> Yes.  you're stressing either the tool, or your knowledge of it.  Put
> the relevant bits in a shell script and tell cron to execute that.
> Then you'll have full control.  It won't be hampered by cron's (by
> design) limitations.

Nope, that didn't work. Thanks for the suggestion though s. keeling. 

Here is what happened after I followed the above advice.

Now the crontab reads:

 * * * * *	root	is_burning || logger get executed.

+ set -x
+ ps -eaf
+ grep -E 'cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed='
root     15306 15295  0 09:29 ?        00:00:00 grep -E cdrecord.* -[dts]ao |cdrdao *write|growisofs.*speed=
+ exit 0

$ is_burning || echo not burning CD/DVD
not burning CD/DVD

I.e., having put the 'ps | grep' part into a shell script, the behavior is
still the same. 

Does it has anything to do with busybox?

Thanks

-- 
Tong (remove underscore(s) to reply)
  http://xpt.sourceforge.net/techdocs/
  http://xpt.sourceforge.net/tools/


Reply to: