0

On my Ubuntu box I have a crontab setup for my normal user that has the following:

0 0 * * * sudo mysqldump -u root -h localhost --all-databases | gzip > /home/<user>/mysqlbackups/db_`date +%F`.sql.gz

When I run the script from shell it runs without any issue.

sudo mysqldump -u root -h localhost --all-databases | gzip > /home/<user>/mysqlbackups/db_`date +%F`.sql.gz

But with it set as a cron job it's not running at all.

I have my user set in my cron.allow file as well (had to create the file as it didn't exist previously).

Kinda stumped at the moment and not sure what else to tweak/try to get this to run automatically at midnight.

Any ideas?

Thanks!

edit: Removed the 'sudo' and it runs fine on my normal shell execution. I'll find out if it runs off the cron automatically tonight.

Valien
  • 111
  • 5
  • So does the sudo run without password? mysqldump and gzip should not require sudo at all normally – Fluffy Oct 08 '13 at 13:36
  • 1
    Why don't you set it as a system cron job? Then the sudo will not be needed, and the effect is the same. – zwets Oct 08 '13 at 13:38
  • Ah, just removed the 'sudo' and the script runs fine as my normal user. Not sure why I had that in there. Probably when I was testing different ways of getting things going. – Valien Oct 08 '13 at 13:45

0 Answers0