CentOS 6.2 cron.daily

centos6.2cron.dailyshell-scripting

I created a new file "dbbackup" in /etc/cron.daily that contains a simple database backup script.

#!/bin/sh

mysqldump -h localhost -u user -p'passord' database_name > /var/www/sites/example.com/backups/db_backup_"`eval date +%u%m%Y`".sql

Now the problem is that this file is not being automatically run, I am fairly new to linux servers but from reading around I found that this is the location that you need to create your cron scripts, but for some reason it doesn't run it, maybe I need to tell CRON some how to run this file in the terminal does anyone know?

Thanks

Best Answer

A few things to do/check

  • add a full path to mysqldump - /usr/bin/mysqldump ...
  • ensure that the file's user/group ownership is root:root

Look in /var/log/cron for error messages. The run parts script logs messages like

Oct 15 03:33:02 centos6 run-parts(/etc/cron.daily)[21777]: starting mlocate.cron
Oct 15 03:33:02 centos6 run-parts(/etc/cron.daily)[21948]: finished mlocate.cron

at the start and end of each job.


From the comments - it appears that cron was not running.

  • Check cron is running - service crond status and start if required service crond start
Related Topic