I'm running Nginx on Ubuntu with the default 'main' log format, which produces output like this:
220.127.116.11 - - [11/Feb/2018:11:43:10 +0000] "GET /blog/ HTTP/1.1" 200 4438 "-" "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)" "-"
I have one master log file that never rotates, which I use with GoAccess (log parsing/reporting software). I wish to delete lines in that file with log entries older than 30 days or so. Can this be done, preferably with a bash one-liner?
I plan to add this to an existing daily cronjob to produce a rolling 30 day report. I'm hoping to use something like this, but I can't quite get it to parse the logs correctly:
sed -i '/<magical-invocation-goes-here> --date="-30 days"/d' example.log