Reputation: 481
I'm posting a portion of the sh script that we use with cron to take a cold backup of our Oracle EBIZ. It works most of the times, fails once in a while because one of the processes the script monitor, fails to stop/terminate
Code portion
su - applprod -c /home/applprod/scripts/Apps_stop.sh
FNDPROCESS=`ps -ef | grep FNDLIBR | grep applprod | wc -l`
echo 'We have still running ' $FNDPROCESS ' FNDLIBR for PROD'
echo 'Please wait...for ' $FNDPROCESS ' seconds!!'
NPROCESS=$FNDPROCESS
while [ $FNDPROCESS -gt 0 ]
do
FNDPROCESS=`ps -ef | grep FNDLIBR | grep applprod | wc -l`
if [ $FNDPROCESS -ne $NPROCESS ]
then
echo 'We have still running ' $FNDPROCESS ' FNDLIBR for PROD'
echo 'Please wait...for ' $FNDPROCESS ' seconds!!'
sleep $FNDPROCESS
NPROCESS=$FNDPROCESS
fi
done
Usually the loop finishes within 3-4 minutes, unless one of the FNDLIBR processes fails to
Now we need to add a max 30 minutes wait time for the loop above, thus, if the wait time is exceeding 29 Minutes, the script should forcefully kill all the processes matching 'FNDLIBR'(Concurrent manager) and come out of the loop.
Please help me :)
Thanks and regards,
Upvotes: 0
Views: 491
Reputation: 5940
I would use the following approach:
This way the process will take 3 or 4 minutes when everything's ok or max 30 minutes when the script monitor fails to terminate.
Upvotes: 0
Reputation: 45
You can use sleep 1740
Your program will pause for 29 minutes and below this line you can write the code which kills all processes which are still running.
Upvotes: 1