Answer the question
In order to leave comments, you need to log in
How to compare the received date from a string in awk and print the string?
so I just get the date, you need to compare it with
echo '12.23.55.11 - - [24/May/2019:08:51:35 +0300] "GET /site/play?cam=1105 HTTP/1.1"' | sed -e 's/\// /' -e 's/\// /' -e '0,/:/s// /' -e '0,/\ +..../s///' -e 's/]/] - /' -e 's/\]//' -e 's/\[//' | awk -F '-' '{print $3}'
echo '22 May 2019 12:49:52' | awk m =`date -d'$0' +%s` m < 1558518592 /var/log/httpd/access_log
Answer the question
In order to leave comments, you need to log in
Alternatively, parse the logs with awk
awk -vDate=`date -d'now-2 hours' +[%d/%b/%Y:%H:%M:%S` '$4 > Date {print Date, $0 }' access_log Taken
from here.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question