Created
October 25, 2013 03:24
-
-
Save CNG/7149013 to your computer and use it in GitHub Desktop.
Count Apache errors by date
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
date; | |
cd /var/log/apache2; mkdir combined_error_logs; | |
rsync -a -e ssh root@www1:/var/log/apache2/error* combined_error_logs/www1; | |
rsync -a -e ssh root@www2:/var/log/apache2/error* combined_error_logs/www2; | |
date; | |
cd combined_error_logs/www1; gunzip *.gz; cd ../..; | |
cd combined_error_logs/www2; gunzip *.gz; cd ../..; | |
date; | |
cat combined_error_logs/*/* | sed -r -n 's/^\[(\w+) (\w+ \w+) ..:..:.. (\w+).+/\3 \2 \1/p' | awk '{count[$1]++}END{for(j in count) print j" "count[j]}' FS=: | sort > errors_by_date.$(date +%Y-%m-%d).txt; | |
rm -rf combined_error_logs; | |
date; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment