Operating System - HP-UX
1833415 Members
3042 Online
110052 Solutions
New Discussion

Re: how to control when omniback script runs

 
SOLVED
Go to solution
David Lane_3
Occasional Advisor

how to control when omniback script runs

Sometimes our databases (Oracle 8.1.7 on HP UX 11i)shutdown with users logged on if the overnight backups run late (usually from a tape drive failure). The backup system is dynamic so it looks for the next available tape drive and so the whole process takes longer if there is a failure.
What would I need to add to the omniback.sh script to prevent it running between 07:00 and 21:00 hours Monday thru Saturday.

Cheers,
Dave Lane
8 REPLIES 8
Michael Tully
Honored Contributor

Re: how to control when omniback script runs

You could shutdown omniback between these hours. You could easily please the stop/start easily into crontab. Only problem I see is if a different type of backup has to run during these hours.

Here is an example that you could use in your crontab file

# Stop omniback
0 7 * * * 0-6 /sbin/init.d/omni stop >/dev/null 2>&1
# Start omniback
59 20 * * * 0-6 /sbin/init.d/omni start >/dev/null 2>&1
Anyone for a Mutiny ?
David Lane_3
Occasional Advisor

Re: how to control when omniback script runs

Thanks Michael,
I didn't really give enough info before.
What I should have mentioned was that the script I wanted to prevent running is not the actual omniback process (which is run remotely and out of my control) but a script that runs on the server to shutdown and startup the databases at the appropriate times (using a semaphore to prevent starting or stopping when already started or stopped).
What I really need is the method to exit the script if it attempts to run between 07:00 and 21:00 Mon to Sat.

Thanks,
Dave
Zafar A. Mohammed_1
Trusted Contributor

Re: how to control when omniback script runs

You can write a simple script which will check :
1. Is Omni is running, if running then don't do anything else start the process.
2. Put the script into cron as mentioned by Mike.

Thanks
Zafar
Steven E. Protter
Exalted Contributor

Re: how to control when omniback script runs

Litte add in.

The script should check the return code on the database shutdown operation.

return_code=$?

If the return code is zero the database shutdown is succesful. If not, your're hung or the database might still be up and you probably want to send an email to someone.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Brian Crabtree
Honored Contributor
Solution

Re: how to control when omniback script runs

I would modify your pre-exec scripts you are using to shutdown the database.

You could do something like the following:

# This gives the current hour in 24hr clock
export CURRHOUR=`date +%H`
if [ $CURRHOUR -gt 7 -a $CURRHOUR -lt 21 ]; then
echo "backup cannot run now"
exit 1
fi

Hope this helps,

Brian
Bill Douglass
Esteemed Contributor

Re: how to control when omniback script runs

You can set up your pre-exec script to check the current time-of-day (date command) and return a non-zero exit status if it is between 7AM and 9PM.


H=`date +%H`
W=`date +%w`

if [ $W -ne 0 ]
then
if [ $H -gt 6 -a $H -lt 22 ]
then
exit -1
fi
fi


This should abort the back-up session.
John Poff
Honored Contributor

Re: how to control when omniback script runs

Hi,

What version of Omniback are you running? I believe there is a setting per session that allows to set the maxiumum amount of time that a session can run before Omniback automatically aborts it. That way, if a session gets hung up or runs slow for some reason, it won't keep running forever.

JP
David Lane_3
Occasional Advisor

Re: how to control when omniback script runs

Thanks to all, this should get me going (or not going as the case maybe)