How to search logs between two timestamps in a log file.
The requirement was to write a shell script for a cron job set for every two hours for all days.
The Script has to scan log files (*.log) for the logs posted only for the last two hours.... and append them in a new file the log file content appears as below ****************************************************** INFO 21 Oct 09 15:44:48 net.oit.utils.JmsReceiver - JMS Opened DEBUG 21 Oct 09 15:44:48 net.oit.excite.mbeans.OutBound - Registered JMS listener INFO 21 Oct 09 15:44:48 net.oit.mbeans.Base - Status now: Running DEBUG 21 Oct 09 15:44:48 net.oit.excite.mbeans.OutBound - Started the JMS queue status = Running DEBUG 21 Oct 09 15:44:48 net.oit.excite.mbeans.OutBound - Completed configureAndRun. DEBUG 23 Oct 09 12:50:14 net.oit.excite.mbeans.OutBound - Started a JMS message...... DEBUG 23 Oct 09 12:50:14 net.oit.excite.mbeans.OutBound - JobId from message ******************************************************** I am clueless abt how to scan/compare based on time stamp seen in above logs. Pls Help!!! |
Well, you could use awk or cut to grab individual fields, but honestly this is perfect for Perl. It even understands dates in that format.
|
gawk
Code:
awk 'BEGIN{ |
All times are GMT -5. The time now is 08:35 AM. |