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 [EMAIL PROTECTED] Sun Apr 22 01:00:01 2007 Envelope-to: [EMAIL PROTECTED] Delivery-date: Sun, 22 Apr 2007 01:00:01 -0300 From: [EMAIL PROTECTED] (Cron Daemon) To: [EMAIL PROTECTED] Subject: Cron [EMAIL PROTECTED] /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 [EMAIL PROTECTED] http://www.jorgensen.org.uk/ [EMAIL PROTECTED] http://karl.jorgensen.com Today's fortune: Yow! Maybe I should have asked for my Neutron Bomb in PAISLEY -- signature.asc Description: Digital signature
Quote or double quote error in crontab
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 [EMAIL PROTECTED] Sun Apr 22 01:00:01 2007 Envelope-to: [EMAIL PROTECTED] Delivery-date: Sun, 22 Apr 2007 01:00:01 -0300 From: [EMAIL PROTECTED] (Cron Daemon) To: [EMAIL PROTECTED] Subject: Cron [EMAIL PROTECTED] /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?
Re: Quote or double quote error in crontab
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 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Sun Apr 22 01:00:01 2007 Envelope-to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Delivery-date: Sun, 22 Apr 2007 01:00:01 -0300 From: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] (Cron Daemon) To: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Subject: Cron [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] /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? I'm not sure about the 'why' but I may have a solution. Put the command line in a script file and put the script file in the crontab. This has several advantages: 1. You can avoid problems like this one. crontab files are quite picky about their contents. 2. You can do all the fancy scripting stuff you're used to using in normal scripts (because it's in fact just another normal script). 3. You can edit the script at any time without having to deal with the crontab command. No worries about accidentally clobbering the crontab content, changing something incorrectly, etc. 4. You can run the script directly to test it. Immediate feedback is available. Generally, most real world admins use this technique (at least the ones I know;). Bob smime.p7s Description: S/MIME Cryptographic Signature