Hello all, been gathering a lot of info from here for the past couple of years, its been very invaluable.
My problem. We have an application that generates log files, on multiple machines, that I need to monitor on a daily basis. These machines also do not have access to the internet, so no email. The log files roll over to new ones when they reach a certain size, and have a time stamp of when they were created, but will have multiple days inside it. I need to monitor the last 24 hours for certain strings (ERROR and Exception). I figured out how multiple ways to pull these out and place them into another file, but I am having a problem just getting the last 24 hours.. Here is what I am using, which was taken from the internet from a couple different places and modified to fit what I need.
Code:
#!/bin/bash
#if there's no 'log' file
if [ ! -e "log-`date '+%Y-%m-%d'`.log" ] ; then
# let's search for the word 'ERROR' in our log and save the output to the newly created file named 'log' with a date stamp.
grep ERROR sanjay.log > "log-`date '+%Y-%m-%d'`.log"
# if however the 'logs' file already exists..
else
# update our log*
grep ERROR sanjay.log >> "log-`date '+%Y-%m-%d'`.log"
fi
Feel free to tell me I am doing it completely wrong

Some examples of what the log looks like:
Code:
2012-06-06 17:30:04,675 INFO [org.springframework.integration.handler.LoggingHandler] - <JobExecution: id=15137, startTime=Wed Jun 06 17:30:04 EDT 2012, endTime=Wed Jun 06 17:30:04 EDT 2012, lastUpdated=Wed Jun 06 17:30:04 EDT 2012, status=COMPLETED, exitStatus=exitCode=COMPLETED;exitDescription=, job=[JobInstance: id=14931, JobParameters=[{INPUT_FILE_NAME=REVERSE_DRAFT5_FILE_2012-06-06-17-30-00, input.file.name=REVERSE_DRAFT5_FILE_2012-06-06-17-30-00}], Job=[reverseDraft5MessageProcessingJob]]>
job-requests
2012-06-06 17:30:04,675 INFO [com.xxxxxxx.xxxxxxx.batch.ap.draft5.ReverseDraft5JobProcessor] - <End of Reverse Draft5 Job at:2012-06-06-17-30-04>