Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 04-04-2008, 05:49 AM   #1
Registered: Jan 2005
Location: NZ
Distribution: Fedora / Debian
Posts: 99

Rep: Reputation: 21
Cron backup script stops running after a few days

I set up a cron script to do backups at 3AM every night, and it ran fine for a few days, then stopped. Here are the contents of the script:


# Auth Details for FTP

# Create backup
tar cjf /tmp/backup/"backup_"$(date +"%d_%m_%Y").tar.bz2 /var/www*

# For testing - instant backup creation
# touch /tmp/backup/"backup_"$(date +"%d_%m_%Y").tar.bz2

# File to upload
FILE=""backup_"$(date +"%d_%m_%Y").tar.bz2"

# Upload file to backup server
mput /tmp/backup/"backup_"$(date +"%d_%m_%Y").tar.bz2

rm /tmp/backup/"backup_"$(date +"%d_%m_%Y").tar.bz2
It isn't the cleanest, but I'm a novice user so

and the line in crontab -e that I put in:

0 3 * * * /root/
Any ideas why this happens?
Old 04-04-2008, 05:55 AM   #2
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 572

Rep: Reputation: 56
Are there any errors in /var/log/cron? Can you see cron attempting to run the script - i.e. has cron died or is there a problem with the script.

Try changing your cron entry so errors are logged:-
0 3 * * * /root/ > /root/bkup.log 2>&1
Has root received mail from cron about the script not working?
Old 04-04-2008, 06:02 AM   #3
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can also look at the mail of the owner of the crontab (that one accessed by the mail command) since the standard error and standard output of cron jobs are redirected there by default (if not explicitly redirected to a file as suggested by blacky_5251).

Edit: uh... sorry, I didn't notice blacky_5251 has already suggested.

Last edited by colucix; 04-04-2008 at 06:03 AM.
Old 04-04-2008, 06:17 AM   #4
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Stretch/Sid, Linux Mint DE
Posts: 4,605

Rep: Reputation: 686Reputation: 686Reputation: 686Reputation: 686Reputation: 686Reputation: 686
Be sure to redirect any output created by the script to somewhere. That is, if you run the script in the console, and you see any output, it should be redirected to either a log file or to /dev/null.

I don't know exactly why, but if you produce output (either to stdout or stderr) and it is going nowhere while you run a job in background it stops after certain time.

Old 04-04-2008, 01:31 PM   #5
Registered: Feb 2007
Posts: 38

Rep: Reputation: 15
file tar.bz2 is generated?
Old 04-05-2008, 05:30 AM   #6
Registered: Jan 2005
Location: NZ
Distribution: Fedora / Debian
Posts: 99

Original Poster
Rep: Reputation: 21
Originally Posted by Gran_Maestre View Post
file tar.bz2 is generated?
Sure is, however that isn't the problem.

It appears the problem was in that I didn't redirect the output of the file to anywhere. After redirecting to /dev/null it appears to be running again. Strange.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
i want to cron a backup script sneakyimp Linux - Software 4 03-25-2008 09:02 PM
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 08:26 PM
a start up script in rc.M stops the following scripts from running nass Slackware 7 05-21-2007 06:21 AM
cron backup job not running dsschanze Linux - General 9 07-29-2005 08:47 PM
cron stops in the middle of the script djzanni Linux - Newbie 6 06-02-2005 05:29 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration