Linux 好用shell脚本集合
LogScrolling.sh
#!/bin/bash cp /var/jfb/log/nginx/access_log.log /var/jfb/log/nginx/access_log_`date -d '-1 day' +%Y-%m-%d`.log echo "" > /var/jfb/log/nginx/access_log.log
AccessCount.sh
#!/bin/bash logName=/var/jfb/log/nginx/access_log_`date -d '-1 day' +%Y-%m-%d`.log accessCount=`wc -l $logName |cut -d " " -f 1` ipCount=`awk '{ip[$1]++}END{for(i in ip){print i,ip[i]}}' $logName |wc -l` echo "access count is :${accessCount}" echo "ip count is :${ipCount}" for i in {0..23}; do if [ $i -lt 10 ];then accessHourCount[$i]=`grep /2015:0${i} ${logName} |wc -l` ipHourCount[$i]=`grep /2015:0${i} ${logName} |awk '{ip[$1]++}END{for(i in ip){print i,ip[i]}}' |wc -l` echo "${i} Hour accessCount is :${accessHourCount[$i]}" echo "${i} Hour ipCount is :${ipHourCount[$i]}" else accessHourCount[$i]=`grep /2015:${i} ${logName} |wc -l` ipHourCount[$i]=`grep /2015:${i} ${logName} |awk '{ip[$1]++}END{for(i in ip){print i,ip[i]}}' |wc -l` echo "${i} Hour accessCount is :${accessHourCount[$i]}" echo "${i} Hour ipCount is :${ipHourCount[$i]}" fi done
相关推荐
linuxwcj 2020-10-21
彼岸随笔 2020-10-20
yutou0 2020-10-17
lishaokang 2020-06-12
jarrygao 2020-11-02
shipinsky 2020-09-23
touchfuture 2020-09-16
hongsheyoumo 2020-09-04
momoku 2020-09-11
ruancw 2020-08-27
TuxedoLinux 2020-08-18
vvu 2020-08-16
downtown 2020-08-11
luvzhan 2020-07-28
maxelliot 2020-06-28
cuixingwudi 2020-06-25
linuxdashencom 2020-06-21
旭灿 2020-06-16