forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanlog.sh
executable file
·61 lines (59 loc) · 1.56 KB
/
cleanlog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
HTML_DIR=/eos/cms/store/unified/www/
LOCAL_DIR=/data/unified/www/
CACHE_DIR=/data/unified-cache/
echo "cleaning .log files in html dir"
for each in `ls $HTML_DIR/logs/*/*.log` ; do
#for each in `find $HTML_DIR/logs/ -name *.log` ; do
age=$((($(date +%s)-$(date +%s -r $each))/86400))
if [ $age -gt 15 ] ; then
echo remove $each
rm -f $each
fi
done
echo "cleaning .time files in html dir"
for each in `ls $HTML_DIR/logs/*/*.time` ; do
age=$((($(date +%s)-$(date +%s -r $each))/86400))
if [ $age -gt 15 ] ; then
echo remove $each
rm -f $each
fi
done
echo "cleaning .json files in html dir"
for each in `ls $HTML_DIR/logs/*/*.json` ; do
age=$((($(date +%s)-$(date +%s -r $each))/86400))
if [ $age -gt 15 ] ; then
echo remove $each
rm -f $each
fi
done
echo "cleaning .log files in local dir"
for each in `ls $LOCAL_DIR/logs/*/*.log` ; do
age=$((($(date +%s)-$(date +%s -r $each))/86400))
if [ $age -gt 15 ] ; then
echo remove $each
rm -f $each
fi
done
echo "cleaning .time files in local dir"
for each in `ls $LOCAL_DIR/logs/*/*.time` ; do
age=$((($(date +%s)-$(date +%s -r $each))/86400))
if [ $age -gt 15 ] ; then
echo remove $each
rm -f $each
fi
done
for each in `ls $LOCAL_DIR/logs/*/*.json` ; do
age=$((($(date +%s)-$(date +%s -r $each))/86400))
if [ $age -gt 15 ] ; then
echo remove $each
rm -f $each
fi
done
echo "cleaning files in cache dir"
for each in `ls $CACHE_DIR/*` ; do
age=$((($(date +%s)-$(date +%s -r $each))/86400))
if [ $age -gt 15 ] ; then
echo remove $each
rm -f $each
fi
done