i have a script that scans a log file every 10 minutes. this script remembers the last line of the log and then uses it to continue monitoring the log when it runs again 10 minutes later.
the script searches the log for a string called MaxClients.
now, how can i make it so that when the script runs, it'll let me know when it finds not just 1 but 3 lines containing MaxClients?
awk 'FNR=>'5034' logfile | egrep MaxClients
sounds simple enough. but there's a catch. lets say the log file can contains:
Warning MaxClient is having issues - please
MaxClients java error...yams potato turkey
MaxClients error Fatal exception known known
MaxClients error Fatal exception known known
Could not complete. Error found. MaxClient initiated
MaxClients error Fatal exception known known
Could not complete. Error found. MaxClient initiated
in the above example, the script should only output the lines:
MaxClients error Fatal exception known known
MaxClients error Fatal exception known known
MaxClients error Fatal exception known known
This is because, this is the line that occurred at least 3 times when the script scanned the log at its 10 minute interval.
this looks like it'll work, but what happens if there are more than 3 occurrences? i think this code will only show the 3 lines. however, what happens if there are more than 3 lines?
i should have been clearer in my post. sorry for that.