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!

script problem

Status
Not open for further replies.

icu812

MIS
Sep 10, 2001
52
0
0
US
I have a script that looks something like this:
It works fine except that I have cron running it every 15 minutes and when my condition is met I get 4 pages. Can someone please tell me how I can have cron run it every 15 minutes and get only one page???? Thank You

## This portion of the script monitors power to SP nodes
##
spmon -d|awk '{print $2":"$4}' > /tmp/mon_power.out
grep off /tmp/mon_power.out > /tmp/mon_power2.out
if [ $? -eq 0 ]
then mail -s &quot;SP node power out msg&quot; icu812@archwireless.net < /tmp/mon_sp_powe
r2.out
mail -s &quot;SP node power out msg&quot; icu812@archwireless.net < /tmp/mon_sp_power2.ou
t
fi
 
Looks like you are trying to send a single page
to two people.
I think you can consolidate the mail command.
mail -s &quot;SP node power out msg&quot; icu812@archwireless.net;icu812@archwireless.net < /tmp/mon_sp_powe
r2.out

How many pages do you get if you run this script
manually from the command line?

Robert Robert G. Jordan

Robert@JORDAN2000.com
Unix Sys Admin
Chicago, Illinois U.S.A.
[lightsaber]
 
I am sending the page to two different people(the pager number you see here is ficticious)I just wanted to know if there was a way I could run the script from cron every 15 minutes but have these people only receiving one page on the occurrence instead of four per hour. thanks
 
ahhh, now I understand...

I think you want to write the page time
to a log file and only page again
if an hour has elasped since the last
page was sent out.

Robert G. Jordan

Robert@JORDAN2000.com
Unix Sys Admin
Chicago, Illinois U.S.A.
[lightsaber]
 
I have thought of a simpler solution.

Check the PRIMARY_LOG and page if necesarry.

Append your current log file to a backup log
cat PRIMARY_LOG >> BACKUP_LOG

clear the PRIMARY_LOG
> PRIMARY_LOG

This may work depending on how often your
primary log gets written to.

Robert


Robert G. Jordan

Robert@JORDAN2000.com
Unix Sys Admin
Chicago, Illinois U.S.A.
[lightsaber]
 
## This portion of the script monitors power to SP nodes
##
PEOPLE=&quot;icu812@archwireless.net,icu812@archwireless.net&quot;

spmon -d|awk '{print $2&quot;:&quot;$4}' > /tmp/mon_power.out
MESSAGE=`grep off /tmp/mon_power.out`
if [ $? -eq 0 ] && [ $MESSAGE -eq &quot; &quot; ]
then
mail -s &quot;SP node power out msg&quot; $PEOPLE < $MESSAGE

fi ***************************************
Party on, dudes!
 
OR id you don't need the /tmp/file

## This portion of the script monitors power to SP nodes
##
PEOPLE=&quot;icu812@archwireless.net,icu812@archwireless.net&quot;

MESSAGE=`spmon -d|awk '{print $2&quot;:&quot;$4}' |grep off`
if [ $? -eq 0 ] && [ $MESSAGE -eq &quot; &quot; ]
then
mail -s &quot;SP node power out msg&quot; $PEOPLE < $MESSAGE

fi ***************************************
Party on, dudes!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top