Last active
December 29, 2015 16:59
-
-
Save sheeplogh/7701112 to your computer and use it in GitHub Desktop.
count hits of some URLs per day from access_log
This file contains 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
#!/bin/sh -e | |
TODAY=`date +%Y%m%d` | |
if [ $# -eq 1 ] | |
then | |
TARGET_DATE=$1 | |
else | |
TARGET_DATE=`date -d "1 day ago" +%Y%m%d` | |
fi | |
echo -e "DATE\t\tURL1\tURL2" | |
while [ "${TARGET_DATE}" != "${TODAY}" ] | |
do | |
echo -e "\ | |
`date -d ${TARGET_DATE} +%Y/%m/%d`\t\ | |
`zcat /var/log/httpd/example.com/access_log.${TARGET_DATE}.gz | grep URL1 | wc -l`\t\t\ | |
`zcat /var/log/httpd/example.com/access_log.${TARGET_DATE}.gz | grep URL2 | wc -l`\ | |
" | |
TARGET_DATE=`date -d "${TARGET_DATE} 1 day" +%Y%m%d` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment