-3

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.

Iberê
  • 113

2 Answers2

4

% 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.

4

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.

Sven
  • 100,763