Quote:
Originally Posted by JJJCR
I guess you can adjust the time range, but more specific time will get specific result. Log file can be very big, if the output is quite long then it's quite difficult to see or check.
|
That's not the point. The problem is that if there are no logs at "/Apr 10 00:00:01/", then absolutely nothing will show up. Moreover, if there are no logs at 'Apr 11 00:01:01', then all lines will show up until there are no more lines in the log. Not really nice.
I had been looking for the same answer for a while. I guess one solution would be to simply do grep for the day you're interested and then pipe it into awk:
grep "Apr 10" | awk -F '[ :]' '$3 >= 15 && $4 >= 30 { print $0 }' - which is going to print all logs starting from 3:30 PM on April 10, even if there is are no logs at exactly 3:30.
As far as your second solution is concerned "awk '/(Apr 10 00:00:01)/ { print $0 }' /var/log/cron)", I really don't understand what you're trying to do. That will only print the lines containing "Apr 10 00:00:01". I don't see the point. He was asking about a line range.