Hi all: I am trying to debug a simple script I wrote to perform some maintenance tasks for ARCserve (script below). My script calls some other scripts to perform the actual work. The problem I have is that these secondary scripts are not starting if run from a cron job. If I run them from terminal, the script runs properly. I have set the cron job to run as root and also set the path for the cron job to be identical to that when logged in as root.

Any ideas? Thanks, Chris.


—-------------------------------------------------------------------------------------------

#!/bin/sh
# Script for running maintenance of CA ARCserve's Ingres database.
# Written by Christopher D. Mosentine

# This script will run a set of commands to perform recommended maintenance
# on ARCserve's Ingres database. It first must stop ARCserve (cstop) and
# test for completion. Secondly it must test if the processes "dbclean"
# and mergecat are running, and if so, wait for them to terminiate. Third,
# the script restarts the ingres database service. Fourth, the script
# runs the required maintenance scripts. Finally, ARCserve gets restarted.

# Write output to the log file
#
LOGFILE=/opt/CA/BrightStorARCserve/logs/db_maint.log

log() {
message="$@"
echo $message
echo "$(date) $message" >>$LOGFILE
}
log "Ingres database maintenance script started."
log $PATH


# Here we will attempt to stop the ARCserve processes. If successful the
# script will continue, else it will exit.
#
arcstopfail=0
arcstopretry=0

cacommd=$(pgrep -o cacommd)
while [ "$cacommd" != "" ]; do
log "ARCserve Process ID: $cacommd is running."
log "Attempting to stop ARCserve."
/opt/CA/BrightStorARCserve/sbin/cstop &
wait

cacommd=$(pgrep -o cacommd)

if [ "$arcstopretry" -eq "2" ]; then
arcstopfail=1
break
else
arcstopretry=$(($arcstopretry+1))
fi
done

if [ "$arcstopfail" -eq "1" ]; then
log "ARCserve services were unsuccessfully stopped."
log "Exiting maintenance script."
exit 0
else
log "ARCserve services were successfully stopped."
fi


# Here we will attempt to stop the Ingres processes. If successful the
# script will continue, else it will exit.
#
dbclean=$(pgrep -o dbclean)
mergecat=$(pgrep -o MergeCat)
dbstopfail=0
dbstopretry=0

while [ "$dbclean" != "" -o "$mergecat" != "" ]; do
log "Ingres Process IDs: $dbclean and/or $mergecat is running."
log "Attempting to stop Ingres."
/opt/CA/BrightStorARCserve/sbin/stopingres
wait

dbclean=$(pgrep -o dbclean)
mergecat=$(pgrep -o MergeCat)

if [ "$dbstopretry" -eq "2" ]; then
dbstopfail=1
break
else
dbstopretry=$(($dbstopretry+1))
fi
done

if [ "$dbstopfail" -eq "1" ]; then
log "Ingres services were unsuccessfully stopped."
log "Exiting maintenance script."
exit 0
else
log "Ingres services were successfully stopped."
fi

# OK, we got this far, so we know ARCserve is stopped and no Ingres processes
# are running. We will now call "startingres" and then startup the maintenance
# script. Finally, once complete, we will restart ARCserve.
#
log "Starting Ingres services in case it was stopped."
/opt/CA/BrightStorARCserve/sbin/startingres
wait

log "Starting database maintenance."
sqlingres < $BAB_HOME/dbase/maintenance/maintain_script.sql
wait

log "Restarting ARCserve services."
/opt/CA/BrightStorARCserve/sbin/cstart
wait


# Scripted completed without error, time to exit with value of 1.
#
log "Maintenance successfully completed."
log ""
exit 1