Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
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. –  Krøllebølle Feb 10 at 9:43
    
My /etc/cron.hourly directory that is, of course. –  Krøllebølle Feb 11 at 14:31

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
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. –  Krøllebølle Feb 10 at 21:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.