0

I'm trying to figure a way to monitor one of our log files.

A cron job runs every 5 minutes which outputs the following line in a log file:

02-16-17 18:40:01 

I'd like something akin to

cat log | grep $DATE $TIME within 10 minutes of $SYSTEMTIME

This log is currently 2MB, so i'm not sure if this is wasting too much resources, not that the server doesn't have lots of extra resources, but cat'ing a 2MB text file seems like a lot of data to parse every 15 minutes.

Suggestions? I've found lots of examples on searching for a specific date/time, but i need the date/time to be relative to when the search is performed.

  • You could start with 'tail -n 1' on the file. If nothing else writes to the file, you could just check its mtime and not even open it. – Jeff Schaller Feb 17 '17 at 0:02
  • Yes I was just going to comment that is the last line in the file – FreeSoftwareServers Feb 17 '17 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.