1

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.

1 Answer 1

2

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.

2
  • Forgot to escape again didn't I! Thanks for your help.
    – Ian
    Dec 15, 2009 at 12:32
  • Common mistake. Any time :)
    – user1931
    Dec 15, 2009 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .