How to only look at the last 10 minutes of a log and grep for statement

I’m looking for a way to only look through the last 10 mins of a WebLogic log file that has line formatting like this.

####<Sep 21, 2018 1:56:20 PM EDT> <Notice> <Stdout>

I want to grep for a specific string and if it fails wait 60 seconds and try again. This would be for RHEL 7, and I’m open to using sed, awk, etc.

Answer

Since you’re using RHEL 7 WebLogic is probably using systemd now. Which means you can take advantage of journalctl and the --since option.

From this article https://www.qualogy.com/techblog/oracle/introducing-weblogic-to-systemd# it looks like you’ll use either wls_nodemanager or wls_adminserver or both. To view both use:

journalctl -u wls_nodemanager -u wls_adminserver --since "10min ago"

Attribution
Source : Link , Question Author : Robert Foster , Answer Author : kenlukas

Leave a Comment