I am having an issue that I can not find any information for while doing an extensive google search.
I have a linux cron, running via crontab, that works great until I try to add a variable date to the title of the file. BUT.. When I run the same command outside the cron, just from the command line, it works fine.. Also, the cron does work if I take out the date part.
Command line code that works:
sudo mysqldump -h mysql.url.com -u user -pPassword intravet sites | gzip > /mnt/disk2/database_`date '+%m-%d-%Y'`.sql.gz
Cron that works:
15 2 * * * root mysqldump -h mysql.url.com -u user -pPassword intravet sites | gzip > /mnt/disk2/database.sql.gz
Cron that DOESN'T work:
15 2 * * * root mysqldump -h mysql.url.com -u user -pPassword intravet sites | gzip > /mnt/disk2/database_`date '+%m-%d-%Y'`.sql.gz
I am not understanding why I can not use the date function while inside a cron? Everything I find says I can, but in practice, I can not.
Server details: Ubuntu 12.04.5
Thank you for any insight.
A "%" character in the command, unless escaped with a backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.– dg99 Apr 17 '15 at 20:39