up vote 1 down vote favorite
1
share [g+] share [fb]

I am trying to schedule a MySQL database dump by using cron but I get an error for some code that I know works when I call directly in Shell.

Here is the code that works perfectly well in Shell:

mysqldump -uUSER -pPASS DB > "/path/to/backup/backup_`date +%Y%m%d%H%M%S`.sql"

However when I set a cron job up it comes back with the following error:

/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file

Please can someone tell me what I am doing wrong?

Cheers, Ian.

link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

Try:

mysqldump -uUSER -pPASS DB > /path/to/backup/backup_`date +"\%Y\%m\%d\%H\%M\%S"`.sql

an easier solution in the future would be to place your command which works in bash, into a shell script, then run the shell script from cron. If it works in bash, it will work in a shell script.

link|improve this answer
Forgot to escape again didn't I! Thanks for your help. – Ian Dec 15 '09 at 12:32
Common mistake. Any time :) – John T Dec 15 '09 at 12:39
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.