2

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

2 Answers 2

3

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
7
  • Hi @Iain my con log only contains crontab cron jobs and no cron.daily. Example: Sep 28 15:33:28 servername crontab[13164]: (root) LIST (root)
    – Alex
    Oct 15, 2012 at 11:32
  • @Alex: grep daily /var/log/cron
    – user9517
    Oct 15, 2012 at 11:39
  • this returns an empty result
    – Alex
    Oct 15, 2012 at 11:46
  • @Alex: You have no other daily jobs then ?
    – user9517
    Oct 15, 2012 at 11:54
  • There are default cron jobs in the cron.daily folder like "logrotate" and "makewhatis.cron" but looking at the cron log they dont run, so maybe the cron doesn't run the cron.daily cron jobs and they need to be setup. Any idea if this is configurable using the terminal commands or there is a config file for this?
    – Alex
    Oct 15, 2012 at 13:10
2

Please make sure that the file is executable:

chmod +x /etc/cron.daily/dbbackup
1
  • Hi @zero_r yes that file was executable.
    – Alex
    Oct 15, 2012 at 11:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .