Date: Thu, 3 Nov 2005 12:18:43 -0800 From: "Brandon Hinesley" <brandonh@hotandcold.biz> To: <freebsd-questions@freebsd.org> Subject: Cron Job will not run. Message-ID: <000d01c5e0b3$ca250a00$6800a8c0@BrandonH> In-Reply-To: <20051103160358.40CB216A456@hub.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
I've been trying to get this working for quite a while, maybe you guys can help me out. This is my first time administering a FreeBSD server (or any server for that matter) and I've only been using FreeBSD (or any other *nix for that matter) for about 6 months. The script below works perfectly when I run it from a console, however, nothing at all seems to happen as evidenced by the backups not being rotated. I don't know if this makes a difference, but the "Backup" folder is a file system on an external hard drive. I am also using samba to share that folder as r/o. I have no way of logging my backup scripts activity yet, any information you might have on doing so would be appreciated. I would also appreciate any ideas on improving efficiency/functionality. Here's part of my /etc/crontab: -------------------- SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin HOME=/var/log #This means every 3 hours, right? 0 */3 * * * root /usr/local/Backup/scripts/bkup-daily # Update the ports using cvsup 45 4 * * * root cvsup /usr/ports/ports-supfile -------------------- There is a new line at the bottom of the crontab file (As there should be) Here's some of /var/log/cron: -------------------- Nov 3 09:00:00 server /usr/sbin/cron[56343]: (operator) CMD (/usr/libexec/save-entropy) Nov 3 09:00:00 server /usr/sbin/cron[56344]: (root) CMD (/usr/libexec/atrun) Nov 3 09:00:00 server /usr/sbin/cron[56345]: (root) CMD (/usr/local/Backup/scripts/bkup-daily) -------------------- Here's a copy of my backup script: -------------------- root@server# cat /usr/local/Backup/scripts/bkup-daily #/bin/sh ##########Initialization########## #--Initialize variables--# #One for every 3 hours in a week numbkups="56" #number of days to keep files in recycle bin before deleting delrcycl="7" files="/usr/local/" docs="Documents" bis="Control" userdata="userdata_temp" recycle=".recycle" scripts="/usr/local/Backup/scripts" bkups="/usr/local/Backup" dbkups="/usr/local/Backup/Daily" #--End variable init--# date #--Check to see if it's being run as root--# if (( `echo $UID` != 0 )); then { echo "You must be root to run this script. Exiting..."; exit; } fi #--End root UID check--# #--Remove recycle bin files older than $delrcycl days prior to backup--# find $files/$docs/$recycle -type f -mtime +${delrcycl}d -exec rm -f {} \; #--End remove recycle bin files--# ##########Rotate backups########## #--Remove oldest backup--# rm -rfv $dbkups/$numbkups #--End remove old backup--# #--Begin backup rotation--# for (( i = $numbkups ; i >= 2 ; i-- )) do let from=i-1 mv -fv $dbkups/$from $dbkups/$i done #--End backup rotation--# ##########Data Transfers########## #--Replicate second to last backup before updating and correct permissions--# chmod 755 $dbkups/0 cd $dbkups/0 find . -print | cpio -dpl --verbose ../1 chmod 755 $dbkups/1 #--End replication of second to last backup--# #--Rsync main data--# rsync -av --delete $files/$docs $dbkups/0/ rsync -av --delete $files/$bis $dbkups/0/ rsync -av --delete $bkups/$userdata $dbkups/0/ #--End Rsync data--# #--Backup Scripts and configs--# cp $scripts/* /usr/local/etc/smb* /usr/local/sbin/smb* /etc/fstab /etc/rc.conf $dbkups/0/ ##########Cleanup######### #--Update the date and time for last backup--# touch -ma $dbkups/0 #--End update the date and time--# #--End script--# date echo exit 0 #--End script--# -------------------- Thanks in advance!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000d01c5e0b3$ca250a00$6800a8c0>