I have several logs with where the time stamp in the logs are "YYYYMMDDHHMM".
I would like to check the last line in each file to make sure the entry is less than 5 minutes old.
My timezone is EST5EDT so the following will work for 1 hour. But I need something easy for 5 minutes ago.
STALE_TIME=$(TZ=$(date +%Z)+5; date '+%Y%m%d%H%M')
I am using ksh and do not have gnu or ksh94.
Is there an easy way I can find what the time was 5 minutes ago?
Example1: current time: 201108081607
stale time: 201108081602
Example2: current time: 201201010001
stale time: 201112312356
I was hoping for something a little cleaner. This is an on demand script I am writing that will parse logs and display just the latest status. Any other ideas? :wall:
Now I just need to figure out how to get the STALE_TIME_S (seconds since January 1, 1970) into STALE_TIME (YYYYMMDDHHMM). I think I can use the date command or maybe TZ. Off the top of their head does anyone know?
---------- Post updated at 03:11 PM ---------- Previous update was at 10:31 AM ----------
I went in a different direction.
Since I already have the OLDTIME in YYYYMMDDHHMM format I simply touch my temp file with it. Then do a find on my temp file and return the file name if its over 5 minutes old.