From owner-freebsd-questions@FreeBSD.ORG Thu Nov 3 20:17:45 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CAEFF16A41F for ; Thu, 3 Nov 2005 20:17:45 +0000 (GMT) (envelope-from brandonh@hotandcold.biz) Received: from mail.themarcomgroup.com (207-114-172-156.gen.twtelecom.net [207.114.172.156]) by mx1.FreeBSD.org (Postfix) with SMTP id 3CE5E43D46 for ; Thu, 3 Nov 2005 20:17:44 +0000 (GMT) (envelope-from brandonh@hotandcold.biz) Received: (qmail 19331 invoked from network); 3 Nov 2005 20:17:41 -0000 Received: from adsl-71-132-117-69.dsl.bkfd14.pacbell.net (HELO BrandonH) (71.132.117.69) by mail.themarcomgroup.com with SMTP; 3 Nov 2005 20:17:41 -0000 From: "Brandon Hinesley" To: Date: Thu, 3 Nov 2005 12:18:43 -0800 Organization: Advanced Mechanical Systems, Inc. Message-ID: <000d01c5e0b3$ca250a00$6800a8c0@BrandonH> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcXgkEGTG1A9K0p4RPiq0kME6iZShwAGes6w X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 In-Reply-To: <20051103160358.40CB216A456@hub.freebsd.org> Subject: Cron Job will not run. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Nov 2005 20:17:46 -0000 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!