Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Crontab and Tar Backups
PostPosted: Sun Feb 14, 2010 6:06 am 
Offline
Senior Newbie

Joined: Thu Apr 30, 2009 12:14 am
Posts: 10
I created a crontab using the crontab -e command, inserting:

Code:
55 4 * * * tar -czvf backups/mud/main/swgi`date +%Y-%m-%d`.tgz swgi 2>&1 >> log/cron.log

4:55 comes and goes and the job never executes and nothing is written to the log file. I never tried adding any scripts to the cron directories in /etc, I suppose that would be the next step. Cron IS running:
Code:
root      1491  0.0  0.1   2048   892 ?        Ss   Feb08   0:00 /usr/sbin/cron

So I assume that perhaps I missed something? Any ideas?


Top
   
PostPosted: Sun Feb 14, 2010 6:23 am 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
Shoie13 wrote:
I created a crontab using the crontab -e command, inserting:

Code:
55 4 * * * tar -czvf backups/mud/main/swgi`date +%Y-%m-%d`.tgz swgi 2>&1 >> log/cron.log



You are merging the stderr into the stdout then redirecting the stdout. This should be the other way around. i.e. command >>log/cron.log 2>&1

Maybe the output is getting mailed to you instead and you are never seeing it.

It would be a good idea to use full paths for 'swgi' and 'log/cron.log' too.

If this job really isn't running you should check /etc/cron.allow and /etc/cron.deny. See man crontab.


Top
   
 Post subject:
PostPosted: Sun Feb 14, 2010 6:40 am 
Offline
Senior Newbie

Joined: Thu Apr 30, 2009 12:14 am
Posts: 10
Code:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file


What would that errror mean? The command runs fine when I use it.


Top
   
 Post subject:
PostPosted: Sun Feb 14, 2010 12:10 pm 
Offline
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
I've found it's better to write commands like that into a shell script. Test the shell script, make sure it works. Then call the shell script from cron.

As sednet says, it's usually a good idea to use explicit paths as well instead of relative paths.


Top
   
 Post subject:
PostPosted: Mon Feb 15, 2010 3:23 pm 
Offline
Senior Newbie

Joined: Thu Apr 30, 2009 12:14 am
Posts: 10
glg wrote:
I've found it's better to write commands like that into a shell script. Test the shell script, make sure it works. Then call the shell script from cron.

That solved the problem and works beautifully. Much thanks.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group