From owner-freebsd-questions@FreeBSD.ORG Fri Oct 14 14:21:23 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 F183416A41F for ; Fri, 14 Oct 2005 14:21:23 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from relay04.roc.ny.frontiernet.net (relay04.roc.ny.frontiernet.net [66.133.182.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id 20D2343D48 for ; Fri, 14 Oct 2005 14:21:22 +0000 (GMT) (envelope-from drew@mykitchentable.net) Received: from filter04.roc.ny.frontiernet.net (filter04.roc.ny.frontiernet.net [66.133.183.71]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id 18DE53582E1 for ; Fri, 14 Oct 2005 14:21:22 +0000 (UTC) Received: from relay04.roc.ny.frontiernet.net ([66.133.182.167]) by filter04.roc.ny.frontiernet.net (filter04.roc.ny.frontiernet.net [66.133.183.71]) (amavisd-new, port 10024) with LMTP id 13772-02-47 for ; Fri, 14 Oct 2005 14:21:22 +0000 (UTC) Received: from blacklamb.mykitchentable.net (67-51-164-214.dsl1.elk.ca.frontiernet.net [67.51.164.214]) by relay04.roc.ny.frontiernet.net (Postfix) with ESMTP id 784673583A2 for ; Fri, 14 Oct 2005 14:21:13 +0000 (UTC) Received: from [165.107.42.123] (unknown [165.107.42.123]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by blacklamb.mykitchentable.net (Postfix) with ESMTP id A68FC1549FC for ; Fri, 14 Oct 2005 07:21:12 -0700 (PDT) Message-ID: <434FBE63.3070905@mykitchentable.net> Date: Fri, 14 Oct 2005 07:19:15 -0700 From: Drew Tomlinson User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: FreeBSD Questions Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-2.3.2 (20050629) at filter04.roc.ny.frontiernet.net Subject: Cron Runs Script Twice - Once With Error and Once Without? 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: Fri, 14 Oct 2005 14:21:24 -0000 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