Date: Fri, 14 Oct 2005 07:19:15 -0700 From: Drew Tomlinson <drew@mykitchentable.net> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Cron Runs Script Twice - Once With Error and Once Without? Message-ID: <434FBE63.3070905@mykitchentable.net>
next in thread | raw e-mail | index | archive | help
I have a script that runs from cron. The script mounts an smbfs share on another machine, copies some files from it, and then unmounts the share. The script is run from a 4.11 machine. It's connecting to a 5.4 box running Samba 3.0.20. I'm trying to figure out why it runs twice. Once with an error and once successfully. I get both emails at 0230 although the error email is listed first. The success email is just as I'd expect but I don't understand the error. The script runs without any errors interactively. Here is the contents of the error email: --- BEGIN --- #! /bin/sh -v # Save *.bsr files to this location backup_dir="/root/bacula_bsr" # Mount Blacklamb's /usr filesystem. Exit if error. /sbin/mount -t smbfs //account@blacklamb/User /blacklamb && echo -e "/blacklamb mounted successfully.\n" || { echo -e Unable to mount /blacklamb\. 1>&2 exit 1 } smbfs: can't get handle to requester (no /dev/nsmb* device) Unable to mount /blacklamb. --- END --- And here is the contents of the success email: --- BEGIN --- #! /bin/sh -v # Save *.bsr files to this location backup_dir="/root/bacula_bsr" # Mount Blacklamb's /usr filesystem. Exit if error. /sbin/mount -t smbfs //account@blacklamb/User /blacklamb && echo -e "/blacklamb mounted successfully.\n" || { echo -e Unable to mount /blacklamb\. 1>&2 exit 1 } /blacklamb mounted successfully. # Test that $backup_dir exists ([ is actually /bin/test). If it does # then continue. Otherwise create $backup_dir. if [ -e $backup_dir ]; then echo -e "$backup_dir exists!\n" 1>&2 else { mkdir $backup_dir && echo -e "Created ${backup_dir}.\n" } || { echo -e "Failed to create ${backup_dir}!!!\n"; exit 1 } fi /root/bacula_bsr exists! # Move existing files to *.yesterday. echo -e "Moving files..." Moving files... for i in `ls ${backup_dir}/*.bsr`; do mv -v "$backup_dir"/`basename $i` "$backup_dir"/`basename $i`\.yesterday done /root/bacula_bsr/BackupCatalog.bsr -> /root/bacula_bsr/BackupCatalog.bsr.yesterday /root/bacula_bsr/bigdaddy.bsr -> /root/bacula_bsr/bigdaddy.bsr.yesterday /root/bacula_bsr/blacklamb.bsr -> /root/bacula_bsr/blacklamb.bsr.yesterday /root/bacula_bsr/blacksheep.bsr -> /root/bacula_bsr/blacksheep.bsr.yesterday /root/bacula_bsr/lillady.bsr -> /root/bacula_bsr/lillady.bsr.yesterday /root/bacula_bsr/restore.bsr -> /root/bacula_bsr/restore.bsr.yesterday /root/bacula_bsr/tv.bsr -> /root/bacula_bsr/tv.bsr.yesterday # Copy files from Blacklamb. echo -e "\nCopying files..." Copying files... for i in `ls /blacklamb/var/db/bacula/*.bsr`; do cp -pv "$i" "$backup_dir" || { echo -e "Error creating ${backup_dir}/${i}!!!" } done /blacklamb/var/db/bacula/BackupCatalog.bsr -> /root/bacula_bsr/BackupCatalog.bsr /blacklamb/var/db/bacula/bigdaddy.bsr -> /root/bacula_bsr/bigdaddy.bsr /blacklamb/var/db/bacula/blacklamb.bsr -> /root/bacula_bsr/blacklamb.bsr /blacklamb/var/db/bacula/blacksheep.bsr -> /root/bacula_bsr/blacksheep.bsr /blacklamb/var/db/bacula/lillady.bsr -> /root/bacula_bsr/lillady.bsr /blacklamb/var/db/bacula/restore.bsr -> /root/bacula_bsr/restore.bsr /blacklamb/var/db/bacula/tv.bsr -> /root/bacula_bsr/tv.bsr # Unmount Blacklamb's filesystem. /sbin/umount /blacklamb && echo -e "\n/blacklamb unmounted successfully." || { echo -e "\nUnable to unmount /blacklamb." 1>&2 exit 1 } /blacklamb unmounted successfully. exit --- END --- Here is the relevant crontab: --- BEGIN --- # Backup bootstrap files from Blacklamb. MAILTO="root" # Run after incrementals at 0230 (everyday except Sunday.) 30 2 * * 1-6 /usr/local/scripts/backup_bootstrap.sh # Run 2-5th Sundays at 0230 - Differentials 30 2 8-31 * 7 /usr/local/scripts/backup_bootstrap.sh # Run 1st Sunday at 0930 - Fulls 30 9 1-7 * 7 /usr/local/scripts/backup_bootstrap.sh --- END --- Any ideas on what is happening here? Thanks, Drew -- Visit The Alchemist's Warehouse Magic Tricks, DVDs, Videos, Books, & More! http://www.alchemistswarehouse.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?434FBE63.3070905>