Script to grep for a string in log files generated in last 15 minutes.

Dear Guru's

I've a requirment to grep for a string in series of log files that are getting generated almost every minute.
I'm looking to schedule a script every 15 mountes,in order to check if the error string has been generated in any of the log files generated in last 15 minutes.

Please suggest any better way to do it.

  • can we make use of -mtime with the specifications in terms of minutes/seconds? , as I seardched and found it's more about days... like 0,1 and 2 ...

Thanks in advance.
Rajiv.

Your problem description is absolutely useless.

Most of it sounds like you want to grep the contents of logfiles, but you do not provide a sample of what you seek (the "error string").

Then you mention -mtime which is a find primary which examines filesystem metadata, not file contents.

Before we can assist, you must coherently summarize your situation. And, please, do provide sample data.

Regards,
Alister

1 Like

Are timestamps on each line? In addition to what alister asked.

1 Like

Ok,
Sorry if my initial explanation has caused any confusion,..
Will explain the situation again..

1.We have process that generates log files every time it runs.
2. This process some time errors out and the error messages are written to these log files.
3. The requirement is to grep these log files for the string "OutOfMemory".
4. We are planning to generate a script which will grep these strings in log files
and send us an o/p with the log file name.

We have an sed to grep for the string,which will provide the logfile name.but we need to schedule an alert every fifteen minutes, to check if the error was reported in any of the log files generated in last 15 minutes.

@Jim - Yes these log files have time stamp associated with them.