Script to grep logs for Errors

Hi Guys,

I want to write a script which can grep the logs (server.log) from a file for Error String and output to a other file.

Problems:

How to know about the errors only between the current restart and not in previous as server.log has earlier restarts also?

thanks for the help! Much appreciated if you can help quckly

Check if any timestamp is added to your log

The timestamps are like this:

2014-02-24 06:51:48,628

awk -v dt=$(date +%Y'-'%m'-'%d) ' dt,0 { if(/Error/) print } ' Logfile

so if server has stopped and started with these strings;

Stop : stopped
Start : started

These two have to be latest(as the server has restarted previously also) and grep the lines between these strings.

Try:

awk '/Start : started/{L=1} /Error/{E[L++]=$0} END{for(i=1;i<L;i++) print E}' logfile