anhnongdan / bimax-counters

Bimax's counter, splitter and extractor. These are completely independent modules and can be deployed on different hosts. Used for both cbimax and sbimax.
0 stars 0 forks source link

[Disk] Reduce raw log and cdn log #12

Closed anhnongdan closed 7 years ago

anhnongdan commented 7 years ago

VNPT server full disk because of log files from FPT.

=> need to review clean_disk cron

anhnongdan commented 7 years ago

Need to add clean_disk cron to this repo:

#!/bin/sh
lock=/tmp/clean_disk.lock
filelist=/tmp/fileslist.txt

#rm -rf /data/cdn/`date +%Y/%m/%d -d '1 day ago'`
rm -rf /data/logs/`date +%Y/%m/%d -d '1 day ago'`
rm -rf /data/logs_fpt/`date +%Y/%m/%d -d '1 day ago'`
if [ -f $lock ];then
        locklast=`stat $lock -c "%Y"`
        now=`date +%s`
        dlay=`echo $now - $locklast | bc`
        if [ $dlay -gt 120 ];then
                rm -f $lock
        fi

fi
if [ -f $lock ];then  exit 0;fi
touch $lock

find  /data/cdn -mindepth 4 -type d -mtime +1 | awk '!/thvl/' | while read dd;do echo $dd;rm -rf $dd;done
find  /data/cdn -mindepth 5 -type f -mmin +1 | awk '!/thvl/' | while read dd;do echo $dd;rm -rf $dd;done
find  /data/cdn -mindepth 4 -type d -mtime +1 -iname '*thvl*' | while read dd;do echo $dd;rm -rf $dd;done
#find  /data/cdn -mindepth 4 -type d -mtime +1| awk '!/thvl/' | while read dd;do echo $dd;rm -rf $dd;done
rm -f $lock
anhnongdan commented 7 years ago

Mr. Vu added #rm -rf /data/cdn/date +%Y/%m/%d -d '1 day ago' and commented out the find /data/cdn commands. This caused the log to not be rotated.

anhnongdan commented 7 years ago

Follow Mr.Vu's solution #14