Cronjob as root?

Posted by Rob on Super User See other posts from Super User or by Rob
Published on 2012-06-24T23:47:37Z Indexed on 2012/06/25 3:18 UTC
Read the original article Hit count: 597

Filed under:
|

I'm having a bit of a problem with cronjobs for backups.

I've set up the following in sudo crontab -e (not under personal account):

0 1 * * * /backups/dobackup

/backups/dobackup contains this:

#!/bin/sh
touch ITRAN
tar -cvpjf /backups/$(date +%d.%m.%Y)_backup.tar.bz2  --exclude=/backups --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev /

The backup file is created, but the file ITRAN is not. Also, the backup file is vastly smaller than expected:

-rw-r--r--  1 rjrudman root      371620259 2012-06-21 12:39 21.06.2012_backup.tar.bz2
-rw-r--r--  1 rjrudman root     1023211449 2012-06-22 18:00 22.06.2012_backup.tar.bz2
-rw-r--r--  1 rjrudman root        1512785 2012-06-23 01:00 23.06.2012_backup.tar.bz2
-rw-r--r--  1 rjrudman root     1023272455 2012-06-24 22:41 24.06.2012_backup.tar.bz2
-rw-r--r--  1 rjrudman root        1514027 2012-06-25 01:00 25.06.2012_backup.tar.bz2

The backups with much larger file sizes are created by manually running sudo /backups/dobackup. It seems the cronjob is failing at some point.. but I have no idea how to debug this issue or where to start.

Any ideas? Running ubuntu 10.04

© Super User or respective owner

Related posts about ubuntu

Related posts about cronjob