Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CRONTAB syntax error

Herer is my CRONTAB file (Ubuntu 10.10):

57 1 * * 2-6  ET=`date --date 'yesterday'+%Y%m%d`;echo $ET 

Even The syntax color indicate that something is wrong. and there is this error:

Subject: Cron <root> ET=`date --date 'yesterday' + (failed) Content-Type: text/plain; charset=ANSI_X3.4-1968 X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/root> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=root>  /bin/sh: Syntax error: EOF in backquote substitution 

But I am not sure whats wrong. Thanks a lot!

like image 593
DocWiki Avatar asked Aug 15 '11 18:08

DocWiki


People also ask

Why crontab scripts are not working?

One of the most frequent causes for the crontab job not being correctly executed is that a cronjob does not run under the user's shell environment. Another reason can be – not specifying the absolute path of the commands used in the script.

Where are crontab errors?

On Ubuntu, Debian and related distributions, you will find cron jobs logs in /var/log/syslog . Your Syslog contains entries from many operating system components and it's helpful to grep to isolate cron-specific messages. You will likely require root/sudo privileges to access your Syslog.

Does crontab use bash?

Cron Uses /bin/sh By Default, Not Bash.


1 Answers

Cron needs to escape the % sign - http://www.hcidata.info/crontab.htm

Try it with a backslash:

57 1 * * 2-6  ET=`date --date 'yesterday' +\%Y\%m\%d`;echo $ET 
like image 63
brightlancer Avatar answered Oct 03 '22 01:10

brightlancer