Reputation: 3538
I'm trying to setup a cronjob on a Ubuntu server to run mysqldump nightly.
In my Google search I've found various tips but I still can't get it to work. Here's what I have right now:
The command (which works fine when run in shell):
/usr/bin/mysqldump -uuser -p****** dbname tablename > /var/sql_dump/dump.sql
I add this to cronjob by running
sudo crontab -e
And adding the line:
0 0 * * * /usr/bin/mysqldump -uuser -p****** dbname tablename > /var/sql_dump/dump.sql
But when it reaches that time (00:00 in this case) no file is created. When running the command in shell it doesn't even take a second to execute so it should be quick.
Per someones suggestion I'm also running
sudo /etc/init.d/cron restart
But to no avail (cron is restarted but no file is still created).
Can anyone spot something I might've missed? Very thankful for responses. :)
Edit: I found the problem (which got missed here when censoring my password): I had % characters in my password which I had to escape. It works fine now :)
Upvotes: 0
Views: 1675
Reputation: 1359
I'm not entirely sure if it is the cause, but I would create a shell script which encapsulates the entire command including parameters and piping, and run this script from cron. This way you make sure the parameters and piping don't influence the cron process.
You could search through your syslog for error messages from cron related to the task. They should be logged there.
Upvotes: 1