1

I am trying to do a mysqldump on the cron for every 5 minutes but it seems that it is not working. I try to execute the mysqldump and it works fine.

mysqldump

mysqldump -uroot -ppassword --single_transaction --opt dbname | gzip > /home/myhome/backup/dbname.`date +"%T"`.sql.gz

cron

*/5 * * * * mysqldump -uroot -ppassword --single_transaction --opt dbname | gzip > /home/myhome/backup/dbname.`date +"%T"`.sql.gz

LOG

May 17 04:35:42 CentOS-63-64-minimal crontab[5605]: (root) LIST (root)
May 17 04:40:01 CentOS-63-64-minimal CROND[5626]: (root) CMD (mysqldump -uroot -ppassword --single_transaction --opt dbname | gzip > /home/myhome/backup/dbname.`date +")

UPDATE

I think I found the problem, it is in date +"%T", because if I replace it with date -I it now works. However, I need to append a date & time on the filename.

2 Answers2

0

This should be a path problem for the cron entry.

Try to use /usr/bin/mysqldump instead of mysqldump, /usr/bin/gzip instead of gzip only, and /usr/bin/date instead of date. Change the path accordingly to your system. Use command whereis to find the paths for the commands.

Luis
  • 283
0

You should put your command in a script, i.e backupmysql, then add this entry in cron:

*/5 * * * * /path/to/backupmysql

cuonglm
  • 2,416