Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The following command on crontab does not work at all.

0 12 * * * mysqldump -hserverhpost -uuser -ppass db > /path/to/backu/$(date +%d-%m-%Y)

I read extensively about this and i cannot see what is wrong with it.

I doesn't seen to work at all.

If i run the mysqldump command alone on the shell, it works fine, but when i send to crontab it doesn't.

Am i missing something?

I want it to run everyday at noon.

Edit:

The problem is: The dump file is not created. the command alone is supposed to store the mysqldump on a file on a folder. which works fine when i run it on the shell, but it doesn't create the file on crontab.

share|improve this question

closed as off topic by mdpc, Ward, Michael Hampton, RolandoMySQLDBA, MadHatter Jan 21 '13 at 9:58

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
It'll be hard to even start helping of you don't tell us what doesn't work, what output you get etc... –  Dennis Kaarsemaker Jan 19 '13 at 14:09
    
The dump is not created. the command alone is supposed to store the mysqldump on a file on a folder. which works fine when i run it on the shell, but it doesn't on crontab –  Ibere Jan 19 '13 at 14:11
1  
So what happens instead? What's in the cron mail? What's in the cron logs? –  Dennis Kaarsemaker Jan 19 '13 at 14:21
1  
But they allow shell access????? –  coincoin Jan 19 '13 at 14:45
1  
If you had searched extensively you'd most likely have found several resources that would point out the two most obvious problems with the crontab entry you show. Take a look athttp://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-‌​can-i-troubleshoot-it which has info on how to debug this. –  Iain Jan 19 '13 at 14:54

2 Answers 2

% is a special character for cron. You have to escape it (\%). It should not prevent cron from working thought. Just the name of the the backup won't be the one expected, and be overwritten each day.

share|improve this answer

Try to give the full path to mysqldump. In many systems, cron has a very limited $PATH compared to regular users or root and mysqldump might not be in cron's $PATH.

share|improve this answer

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