I want to filter the log written in the last 10 minutes in the access.log file of Nginx on Ubuntu 16.04. I tried using the below line but only the log for that minute is filtered.
awk -v d1="$(date --date="-10 min" "+%d/%b/%Y:%H:%M")" -v d2="$(date "+%d/%b/%Y:%H:%M")" '$0 > d1 && $0 < d2 || $0 ~ d2' /usr/local/nginx/logs/access.log
This is the date format for the logs that are written:
12/Apr/2018:12:49:03
Any help would be greatly appreciated.