Created
November 1, 2024 17:26
-
-
Save parsibox/263d0b2a813702064f6ce949b2314351 to your computer and use it in GitHub Desktop.
nginx error log get clientip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -oP '(?<=client: )[\d.]+(?=,)' /var/log/nginx/error.log | sort | uniq -c | sort -nr | head -n 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mv /var/log/nginx/error.log /var/log/nginx/$(date +%F).error.log && kill -USR1 $(cat /run/nginx.pid)
mv /var/log/nginx/access.log /var/log/nginx/$(date +%F).access.log && kill -USR1 $(cat /run/nginx.pid)