Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cron help



 James Kramer wrote: 
> I have a script that I use to backup my data files to the Amazon S3. 
> For it to work I need to run is as sudo (root). 

First, does it really need to be root? 


> I placed this script into /etc/cron.weekly. 
> It does not run in cron. 

As Matthew Gillen asked, have you set the execute permission on the file? 

Have you tried: 

# sudo /etc/cron.weekly/backup 

(assuming your script is called backup) and does it run? 

I presume you've checked root's email and the system log where cron 
errors get written. 

Also, Matt mentioned paths. Check the cron man page for more information 
on how the environment is set up for programs executed from a crontab. 
Best to use absolute paths, especially for stuff being ran as root. 


> #!/bin/bash 

/bin/sh is the preferred shell for scripts. (Usually linked to bash.) 

> cd /usr/local/s3sync 
> 


> echo -e "To: ${EMAIL}\nSubject: s3backup results\nContent-type: 
> text/plain\n\n" > /tmp/s3backup.log 

If you just echo to STDOUT or STDERR, cron will automatically email the 
data to root. 

> ../s3sync.rb  ${EXCMDS} --delete -r /etc/ jdata_backup:etc >> /tmp/s3backup.log 
> ../s3sync.rb  ${EXCMDS} --delete -r /jdata/ jdata_backup:jdata >> 
> /tmp/s3backup.log 
... 

You could rewrite that as: 

cd /usr/local/s3sync && ( 
   echo -e "To: ${EMAIL}\nSubject: s3backup results\nContent-type: 
text/plain\n\n" 
   ../s3sync.rb  ${EXCMDS} --delete -r /etc/ jdata_backup:etc 
   ../s3sync.rb  ${EXCMDS} --delete -r /jdata/ jdata_backup:jdata 
   ../s3sync.rb  ${EXCMDS} --delete -r /home/jmkramer/.tomboy \ 
     jdata_backup:tomboy 
) | ${SENDMAIL} "${EMAIL}" 


  -Tom 

-- 
Tom Metro 
Venture Logic, Newton, MA, USA 
"Enterprise solutions through open source." 
Professional Profile: http://tmetro.venturelogic.com/

-- 
This message has been scanned for viruses and 
dangerous content by MailScanner, and is 
believed to be clean. 

_______________________________________________ 
Discuss mailing list 
[hidden email] 
http://lists.blu.org/mailman/listinfo/discuss
 


BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org