crontab not working with date entry

Tag: crontab , freebsd Author: zhongyp86 Date: 2014-02-08

Can anyone let me know why this does not work:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.oYrOhTNQ48 installed on Wed Feb 19 17:10:46 2014)
# (Cron version -- $FreeBSD: src/usr.sbin/cron/crontab/crontab.c,v 2008/10/02 02:57:24 kensmith Exp $)

## backup
0 */4 * * * /usr/local/mysql-5.1.50/bin/mysqldump -e -u username -ppassword sm | /usr/bin/gzip > /tmp/database.`date +%m-%d-%Y-%T`.sql.gz
* * * * * /usr/bin/touch /usr/home/dennis/thisworks
* * * * * env > ~/env.output

Unfortunately I have no access to the log files.. so I can't see any errors. manually it works fine. If I take out the date +%m-%d-%Y-%T it works too. I even tried full path to date with no luck.

A little help?

A couple of questions: (1) Is this the crontab for your user account? (2) why is your file showing the "DO NOT EDIT THIS FILE" line? This shouldn't happen if you're editing it properly with crontab -e, and (3) by "does not work" what are the symptoms? Is there no output file at all in /tmp?

Other Answer1

Do you have shell access ?

Best way to just run

/usr/local/mysql-5.1.50/bin/mysqldump -e -u username -ppassword sm | /usr/bin/gzip > /tmp/database.`date +%m-%d-%Y-%T`.sql.gz

in shell. you will then see whatever the error is.

Once the bash command is working then move it to cron and just apply the date setting.