1

I have set up a cron job on my local Ubuntu 12.04 server to log on a remote server through a passwordless ssh connection and run mysqldump on a database on that server once a day. My problem is that, in addition to running mysqldump at 00:00 every day, it is for some reason also run at HH:17 at every hour, thereby filling up the disk fairly rapidly. The job in my crontab is set up as:

@daily  /bin/bash /home/backup/scripts/db_backup

The most important parts of the script db_backup looks like this:

#!/bin/bash

# Sets the properties and folders to be backed up
host_name=admin@the_host.com
db_name=the_db_name
db_backup_folder_at_host="~/db_backup"

# Dumps the mysql database
{ # Try
    ssh ${host_name} "mysqldump ${db_name} > ${db_backup_folder_at_host}/backup$(date +%F_%R).sql" &&
    echo "$(date) SUCCESS! mysqldump of database"
} || { # Catch
    echo "$(date) FAILURE! mysqldump of database"
}

At the remote server I have specified a .my.cnf file for the database (in the home folder) like this:

[mysqldump]
user=USERNAME
password=PASSWORD
host=MYSQLSERVER

and this works fine.

The crontab is successfully installed for the super user of my local Ubuntu 12.04 server. I have tried rebooting the server, but that does not fix the problem. Running sudo ps -A | grep cron at the Ubuntu server produces 1166 ? 00:00:00 cron as output, so only one process is running. Running sudo crontab -l shows the daily cron job above, while running crontab -l shows that no jobs are installed for the regular user. There are no cron jobs running on the remote server.

Can anyone give me a hint on how this can be happening? Where can I search for clues?

Note that I have also tried the following for the crontab, but mysqldump is still run every HH:17:

0 0 * * *   /bin/bash /home/backup/scripts/db_backup
2
  • 1
    Just came to my mind that I have not checked my /etc/cron.hourly file recently. I'll check that when I get back home. Commented Feb 10, 2014 at 9:43
  • My /etc/cron.hourly directory that is, of course. Commented Feb 11, 2014 at 14:31

1 Answer 1

1

Although I'm running a different version of ubuntu, my /etc/crontab runs the hourly script 17mins past the hour.

SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

Have a look in /etc/cron.hourly

1
  • 1
    Yup, that's it. Had an old version of the backup script in the /etc/cron.hourly folder. As a side note my /etc/crontab file in Ubuntu 12.04 looks the same as yours. Commented Feb 10, 2014 at 21:25

You must log in to answer this question.

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