全部博文(178)
分类: LINUX
2008-04-11 14:22:09
/ 2008-03-26 16:55:34
#!/bin/sh lastlogdate=`date "+%Y%m%d" -d yesterday` touch /var/log/web/sery.com-access$lastlogdate.log for i in /var/log/web/sery.com-access$lastlogdate.log.* do cat $i >> /var/log/web/sery.com-access$lastlogdate.log rm -f $i done touch /var/log/web/sery.com-access$lastlogdate.log gzip /var/log/web/sery.com-access$lastlogdate.log if [[ -f /var/log/web/sery.com-access$lastlogdate.log.gz ]] then mv /var/log/web/sery.com-access$lastlogdate.log.gz /var/log/weblog-backup/ fi rm -rf `find /var/log/weblog-backup/ -atime 7` |
5 0 * * * /usr/local/bin/merge_log.sh |
[root@www1 ~]#useradd –d /var/log/weblog-backup -s /sbin/nologin sery [root@www1 ~]#passwd sery [root@www1 ~]#chmod 755 –R/var/log/weblog-backup |
#!/bin/bash wget --active-ftp -m --directory-prefix=/root/logs/web1/ --tries=3\ --output-file=/root/script/weblog-get.log\*.gz wget --active-ftp -m --directory-prefix=/root/logs/web2/ --tries=3\ --output-file=/root/script/weblog-get.log \ /sery*.gz |
crontab –e 00 02 * * * /usr/local/bin/weblog-get.sh |
#!/bin/bash #define variables AwsLogDir=/root/logs/awstats_log Web1Log=/root/logs/web1 Web1OrigLog=$Web1Log/sery.com-access$(date +%Y%m%d --date='1 days ago').log.gz Web2Log=/root/logs/web2 Web2OrigLog=$Web1Log/sery.com-access$(date +%Y%m%d --date='1 days ago').log.gz OldFile=/root/logs/awstats_logs/sery.com-access$(date +%Y%m%d --date='4 days ago').log* ######################################################################### #get logfiles cd $Web1Log if [[ -f $Web1OrigLog ]] then gunzip -d $Web1OrigLog fi FileLog1=sery.com-access$(date +%Y%m%d --date='1 days ago').log if [[ -f $FileLog1 ]] then mv sery.com-access$(date +%Y%m%d --date='1 days ago').log $AwsLogDir/17k.com-access$(date +%Y%m%d --date='1 days ago').log.1 fi cd $Web2Log if [[ -f $Web2OrigLog ]] then gunzip -d $Web2OrigLog fi FileLog2=sery.com-access$(date +%Y%m%d --date='1 days ago').log if [[ -f $FileLog2 ]] then mv sery.com-access$(date +%Y%m%d --date='1 days ago').log $AwsLogDir/sery.com-access$(date +%Y%m%d --date='1 days ago').log.2 fi ######################################################################### # conbine two web logs to one cd $AwsLogDir File1Log=sery.com-access$(date +%Y%m%d --date='1 days ago').log.1 File2Log=sery.com-access$(date +%Y%m%d --date='1 days ago').log.2 if [[ -f $File1Log && -f $File2Log ]] then cat $File1Log $File2Log >sery.com-access.log fi if [[ -f $OldFile ]] then rm $OldFile fi |
(1) awstats wget big_mirror=0 (2) 解压 tar xvf wstats-6.7.tar.gz mv awstats-6.7 /usr/local/awstats |
cd /usr/local/awstats/tools 执行配置脚本,这是一个交互程序,可根据自己的实际情况回答 perl awstats_configure.pl ----- AWStats awstats_configure 1.0 (build 1.7) (c) Laurent Destailleur ----- This tool will help you to configure AWStats to analyze statistics for one web server. You can try to use it to let it do all that is possible in AWStats setup, however following the step by step manual setup documentation (docs/index.html) is often a better idea. Above all if: - You are not an administrator user, - You want to analyze downloaded log files without web server, - You want to analyze mail or ftp log files instead of web log files, - You need to analyze load balanced servers log files, - You want to 'understand' all possible ways to use AWStats... Read the AWStats documentation (docs/index.html). -----> Running OS detected: Linux, BSD or Unix -----> Check for web server install Found Web server Apache config file '/usr/local/apache2/conf/httpd.conf' -----> Check and complete web server config file '/usr/local/apache2/conf/httpd.conf' -----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf' File awstats.model.conf updated. -----> Need to create a new config file ? Do you want me to build a new AWStats config/profile file (required if first install) [y/N] ? |
LogFile=/root/logs/awstats_log/17k.com-access.log |
crontab –e 00 06 * * * /usr/local/bin/awstats_update.sh |