|
@@ -0,0 +1,125 @@
|
|
|
+#!/bin/bash
|
|
|
+#Hostname=`hostname|awk -F '.' '{print $1}'`
|
|
|
+Date=`date -d "-1 day" +%F`
|
|
|
+Date1=`date -d "-6 day" +%F`
|
|
|
+AccessDIR=/data1/log/access
|
|
|
+IndexDIR=/data1/log/index
|
|
|
+DevlogDIR=/data1/log/devlog
|
|
|
+
|
|
|
+# access log path
|
|
|
+DIR1=/data/log/other
|
|
|
+
|
|
|
+# index log path
|
|
|
+DIR2=/data/log/index
|
|
|
+
|
|
|
+# devlog log path
|
|
|
+DIR3=/data/log/devlog
|
|
|
+
|
|
|
+#check dir
|
|
|
+function check_access(){
|
|
|
+ if [ ! -d $AccessDIR ]
|
|
|
+ then
|
|
|
+ mkdir -p $AccessDIR
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function check_index(){
|
|
|
+ if [ ! -d $IndexDIR ]
|
|
|
+ then
|
|
|
+ mkdir -p $IndexDIR
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function check_devlog(){
|
|
|
+ if [ ! -d $DevlogDIR ]
|
|
|
+ then
|
|
|
+ mkdir -p $DevlogDIR
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function accsess(){
|
|
|
+ check_access
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $DIR1
|
|
|
+ cp access_log.$Date* $AccessDIR
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function index(){
|
|
|
+ check_index
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $DIR2
|
|
|
+ cp chapterIndex.log.$Date $IndexDIR
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function devlog(){
|
|
|
+ check_devlog
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $DIR3
|
|
|
+ cp idfaLog.log.$Date $DevlogDIR
|
|
|
+ cp idfaSuccessLog.log.$Date $DevlogDIR
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function remove_access(){
|
|
|
+ accsess
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $DIR1
|
|
|
+ rm -f access_log.$Date*
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function remove_index(){
|
|
|
+ index
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $DIR2
|
|
|
+ rm -f chapterIndex.log.$Date
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function remove_devlog(){
|
|
|
+ devlog
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $DIR3
|
|
|
+ rm -f idfaLog.log.$Date idfaSuccessLog.log.$Date
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+function remove_log(){
|
|
|
+ remove_access
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $AccessDIR
|
|
|
+ find /data1/log/access/ -type f -name "access_log.*" -mtime +6|xargs rm -f
|
|
|
+ fi
|
|
|
+ remove_index
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $IndexDIR
|
|
|
+ rm -f chapterIndex.log.$Date1
|
|
|
+ fi
|
|
|
+ remove_devlog
|
|
|
+ if [ $? -eq 0 ]
|
|
|
+ then
|
|
|
+ cd $DevlogDIR
|
|
|
+ find /data1/log/devlog/ -type f -name "*.log.*" -mtime +30|xargs rm -f
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+remove_log
|
|
|
+
|
|
|
+find $DIR1 -mtime +7 -name "*.log.*" -exec rm -rf {} \;
|
|
|
+find $DIR1/rec -mtime +7 -name "*.log.*" -exec rm -rf {} \;
|
|
|
+find /data/log/devlog -mtime +7 -name "*.log.*" -exec rm -rf {} \;
|
|
|
+find /data/log/bookincharge -mtime +7 -name "*.log.*" -exec rm -rf {} \;
|
|
|
+find /data/log/cmread -mtime +7 -name "*.log.*" -exec rm -rf {} \;
|
|
|
+find /data/log/novelweb -mtime +7 -name "*.log.*" -exec rm -rf {} \;
|
|
|
+find /data/log/devlog/bookShelf -mtime +1 -name "*.log*" -exec rm -rf {} \;
|
|
|
+find /data/log/perf/ -type f -name "perf.log.*" -mtime +6|xargs rm -f
|