Backup database uses crontab with date function
I can use this command
mysqldump -u"root" myDB| gzip > mydb_`date +%d-%m-%Y`.sql.gz but when run in crontab
* * * * * mysqldump -u"root" myDB| gzip > mydb_`date +%d-%m-%Y`.sql.gz (this error occurs by function date, when I delete it, crontab works well)
on ubuntu, this error occurs in the log file.
ubuntu CRON[xxxx] (user) CMD(mysqldump -u"root" myDB| gzip > mydb_`date+) ubuntu CRON[xxxx] (CRON) error ( grandchild #5353 failed with exit status 2) ubuntu CRON[xxxx] (CRON) info (no MTA installed, discarding output) From man 5 crontab :
The `` sixth '' field (the rest of the line) indicates the command that should be working.
The entire command line, up to a new line or% character, will be executed by / bin / sh or the specified shell in the SHELL variable of the crontab file.
The percent signs (%) in the command, if you do not escape with a backslash (), will be changed to newline characters and all data after the first% is sent to as standard input. It is not possible to split a single line command into multiple lines, for example, a shell ending with "\".