Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted


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.

share|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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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