troubleshooting Question

script won't run in cron but runs on the command line

Avatar of David Aldridge
David AldridgeFlag for United States of America asked on
Scripting LanguagesLinux
34 Comments3 Solutions275 ViewsLast Modified:
This script runs just fine when I run it from the command line, but it bombs on the mailx piece when I try to run it from a cron job.  Any ideas?

Thanks in advance,
David


#!/bin/ksh

now=current
set -x
LOGDIR=/opt/VRTSsfmcs/Backup
THIS_SCRIPT=`basename $0`
LOGFILE=$THIS_SCRIPT_$now.log
MAILLIST="david@itmemphis.com"
MAILSTRING="lnxutil VOM Backup Result $now"

function logger {

        mkdir /opt/VRTSsfmcs/Backup/VOM_Backup_$now
        echo "Creating Logs"

                echo "Creating Logfile"
                mkdir -p $LOGDIR
                exec 1> $LOGDIR/$LOGFILE 2>&1
                mv $LOGDIR/$LOGFILE /opt/VRTSsfmcs/Backup/VOM_Backup_$now
}

function clean {
        echo "Removing old file"
        rm -r  /opt/VRTSsfmcs/Backup/VOM_Backup_last
        echo "Changing file name"
        mv  /opt/VRTSsfmcs/Backup/VOM_Backup_$now  /opt/VRTSsfmcs/Backup/VOM_Backup_last

        echo "Clean Complete"
}

function Do_Backup {
        echo "Running the backup process...."

        /opt/VRTSsfmcs/config/adm/vom_bkup.pl --backup /opt/VRTSsfmcs/Backup/VOM_Backup_$now

        echo "Backup Complete"
}

function mailer {
        echo "Sending Email to david@itmemphis.com"
        cat /opt/VRTSsfmcs/Backup/VOM_Backup_$now/$now.log | mailx -s "$MAILSTRING" $MAILLIST
}

clean
logger
Do_Backup
mailer
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 34 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 34 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros