LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

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

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:

Code:
#!/bin/sh

# Auth Details for FTP
USERNAME="<SNIP>"
PASSWORD="<SNIP>"
SERVER="<SNIP>"

# 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
ncftp -u $USERNAME -p $PASSWORD $SERVER<<EOF
mput /tmp/backup/"backup_"$(date +"%d_%m_%Y").tar.bz2
quit
EOF

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:

Code:
0 3 * * * /root/bkup.sh
Any ideas why this happens?
 
Old 04-04-2008, 05:55 AM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569

Rep: Reputation: 54
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:-
Code:
0 3 * * * /root/bkup.sh > /root/bkup.log 2>&1
Has root received mail from cron about the script not working?
 
Old 04-04-2008, 06:02 AM   #3
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,361

Rep: Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910Reputation: 1910
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
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 3,978

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
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.

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

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

Original Poster
Rep: Reputation: 21
Quote:
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.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 07:45 AM.

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