![]() |
|
|
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 |
| To find the time difference between two lines of the same log file | satyakam | Shell Programming and Scripting | 2 | 04-30-2008 11:46 AM |
| calculating sum of fields in a file | dsravan | Shell Programming and Scripting | 4 | 01-03-2008 01:00 PM |
| Calculating field using AWK, or GAWK script | Trellot | UNIX for Dummies Questions & Answers | 4 | 10-28-2007 03:43 PM |
| NTP - with time difference | shauche | AIX | 0 | 07-02-2007 02:21 AM |
| time difference | decci_7 | UNIX for Advanced & Expert Users | 3 | 10-09-2006 04:57 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
calculating the time difference, when the script was executed and the currenent file
Hi,
I has created the shell script in HP_UX 11.23 and using the command, echo $(date +%Y%m%d%H%M%S) > $DIR/alert, placing the time of running the script into a file alert. I want to compare the time in the above file alert with the current time.If difference is more than 5 min, then print the message. |
|
||||
|
calculating the time difference, when the script was executed and the current time
Hi,
I has created the shell script in HP_UX 11.23 and using the command, echo $(date +%Y%m%d%H%M%S) > $DIR/alert, placing the time of running the script into a file alert. I want to compare the time in the above file alert with the current time.If difference is more than 5 min, then print the message. |
|
||||
|
Hmm "stat" is not a HP UX command. It's on some Linux distributions but not a portable unix command.
Personally I'd use cron to run the script every 5 mins during the monitoring period. Start the cron 5 minutes earlier than the start of your monitoring period. Define a timestamp filename containing todays date: YYYYMMDD="`date +%Y%m%d`" my_timestamp="my_prefix${YYYMMDD}" At the start of the script if the timestamp file does not exist, create it with unix "touch" and exit. On the second and subsequent invocations the file will exist. You can then easily check whether the alert file timestamp is more than 5 minutes old with "find ... -type f ! -newer $my_timestamp ... ". At the end of the script "touch" the timestamp file ready for next time. You will need some code to delete old timestamp files, so choose a unique prefix for the timestamp filename. Beware: Recursive alert log checkers can easily generate multiple alarms for one incident unless you code to deal with this. |
|
||||
|
I cannot use the cron,as i am running the script through automation tool.
Also /tmp/nitin -type f -newer timestamp.sh is running fine but /tmp/nitin -type f! -newer timestamp.sh is giving error bad -type f!. Is there any other way, to know that the particular file is older than 5 min. |
![]() |
| Bookmarks |
| Tags |
| linux, solaris |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|