Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron launched script

Status
Not open for further replies.

icu812

MIS
Sep 10, 2001
52
0
0
US
I have a korn shell script that is launched by cron every 5 minutes. This script is checking ORACLE processes to make sure that they are up and running. When it finds one that is down, I am paged every 5 minutes until I can fix the condition that causing me to get paged. Can someone please give me some tips on how I would set up this script to run every 5 minutes from cron but have it page me once an hour. Thanks
 
Why don't you write out a file as part of the script whenever the process isn't running.

Use the time the file was created to decide whether to page you or not on subsequent running of transactions. You could use something like "touch" on the file depending on how you do your design.

Greg
 
That sounds like a great idea. Can you please elaborate using the commands I'd use in my script?????? Thank you very much.
 
Something along these lines should do it. You could make this more elegant with a loop. However this illustrates the logic well and I don't have a unix machine at home to test a more complicated script. Hopefully this demonstrates one way of doing it(and is syntactically correct).

Basic concept is 12 files, one for every five minutes. Only PAGE on the 12th file. If no files(named tester* below) exist your current script creates tester12(use "touch tester12" in your script) whenever Oracle is down and calls this script. This script will only page you every hour.

!/bin/ksh

if [ -f tester12 ]
then
echo "PAGE HERE"
mv tester12 tester11
exit
fi

if [ -f tester11 ]
then
mv tester11 tester10
exit
fi

if [ -f tester10 ]
then
mv tester10 tester9
exit
fi
.
.
.
.
if [ -f tester1 ]
then
mv tester1 tester12
exit
fi

 
another option would be to have a second cron job/script
that pages on the hour and disable the paging feature
in the first. Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
sh.gif


FREE Unix Scripts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top