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!
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.
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.
Cron Uses /bin/sh By Default, Not Bash.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With