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

Re: Quote or double quote error in crontab



On Tue, May 08, 2007 at 05:55:48PM -0300, Valdir Marcos wrote:
> In crontab, I have:
> 00 01   * * 1-7 root    /usr/bin/sarg -f /etc/squid/sarg-diario.conf -d `(date
> --date "1 day ago" +%d/%m/%Y)`-`(date --date "1 day ago" +%d/%m/%Y)`
>  
> And this line generate the following message:
> 
> From x@x.net Sun Apr 22 01:00:01 2007
> Envelope-to: x@x.net
> Delivery-date: Sun, 22 Apr 2007 01:00:01 -0300
> From: x@x.net (Cron Daemon)
> To: x@x.net
> Subject: Cron <x@xr> /usr/bin/sarg -f /etc/squid/sarg-diario.conf -d `(date
> --date "1 day ago" +
> X-Cron-Env: <SHELL=/bin/sh>
> X-Cron-Env: <PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin>
> X-Cron-Env: <HOME=/x>
> X-Cron-Env: <LOGNAME=x>
> Date: Sun, 22 Apr 2007 01:00:01 -0300
>  
> /bin/sh: -c: line 1: unexpected EOF while looking for matching ``'
> /bin/sh: -c: line 2: syntax error: unexpected end of file
>  
>  
> When I execute this exact line in the prompt there is no error message. The
> command is executed perfectly.
>  
> How can I solve this problem?

According to "man 5 crontab" you will need to escape the '%'-signs.  
Otherwise cron will send anything following the first %-sign to the 
command's stdin (with subsequent %-signs being transformed into 
newlines)...

-- 
Karl E. Jorgensen
karl@jorgensen.org.uk  http://www.jorgensen.org.uk/
karl@jorgensen.com     http://karl.jorgensen.com
==== Today's fortune:
Yow!  Maybe I should have asked for my Neutron Bomb in PAISLEY --

Attachment: signature.asc
Description: Digital signature


Reply to: