I am trying to set up a crontab job to back up a mysql DB every day at a specific time.
I do the following steps (as root):
crontab -e
00 11 * * * root /root/my_Backups/productionbDB-backup.sh >> mybackup.log 2>&1
service crond restart
I waited to be 11 am, but nothing happened.
I confirmed that if the command /root/my_Backups/productionbDB-backup.sh
is issued from the command line, as root, it creates the backup.
What am I missing?
2
Answers
00 11 * * * root /root/my_Backups/productionbDB-backup.sh >> mybackup.log 2>&1
-> what is theroot
word doing there? What you should have is00 11 * * * /root/my_Backups/productionbDB-backup.sh >> mybackup.log 2>&1
You have used the format for installing crontabs into system wide /etc/cron.d/
<time spec> <user> <command>
As you are installing into a users personal crontab (for example on CentOS /var/spool/cron/{user}) using
crontab -e
the format ommits the user specification<time spec> <command>
More information available in the cron manpage here