![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "sed" to check file size & echo " " to destination file | jockey007 | Shell Programming and Scripting | 7 | 04-28-2009 02:08 AM |
| shell "if" condition not executed | himvat | Shell Programming and Scripting | 8 | 12-15-2008 11:08 AM |
| Why generate "ash and bash" different output for same bash script? | s. murat | Shell Programming and Scripting | 0 | 05-26-2008 07:19 AM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| IF Condition in ".sh" File (Beginner) | salanalani | HP-UX | 2 | 05-30-2007 07:11 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
BASH condition for "File older than 1 hour"
I have a monitor script that executes every 5 minutes. I am adding functionality that will detect if a previous execution is hung. I have managed to do that by using a flag that is created when the monitor starts and is then removed when the monitor finishes. The hang check simply looks to see if the flag exists and if it does, trigger an alert. Problem is, if a monitor hangs, every subsequent execution shoots off an alert every 5 mins (that's 96 alerts in the morning if it hangs just after I go to bed...)
So, what I need is a second test that will check to see if the flag is older than 1 hour. That way I'll get the initial alert and then one every hour after that instead of every 5 mins. I need a simple condition for my script: Code:
if [ -a monitor_running_flag ]
then
if [ -a hung_monitor_flag ]
echo "alert fired already"
else
echo "previous execution of monitor might be hung"
touch hung_monitor_flag
fi
fi
if [ monitor_running_flag older than 1 hour ]
then
echo "monitor still hung, check on it"
fi
Thanks! |
| Bookmarks |
| Tags |
| bash, file, if condition, older |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|