forked from papampi/nvOC_by_fullzero_Community_Release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_rotate
68 lines (55 loc) · 1.89 KB
/
log_rotate
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
62
63
64
65
66
67
68
#!/bin/bash
# log rotation by papampi for nvOC by fullzero, v0019-2.0 Community Release
nvOC_Ver="nvOC v0019-2.0 - Community Release"
log_rotate_ver="v0019-2.0.002"
source /home/m1/1bash
echo "Log Rotate for $nvOC_Ver"
echo "Version: : $log_rotate_ver"
echo ""
while true
do
TIMEIN=$LOG_ROTATE_INTERVAL
TIMEOUT=$(($TIMEIN * 3600))
# Rotating wdog logs
WDOG_LOG_FILE="/home/m1/5_watchdoglog"
if [ -e "$WDOG_LOG_FILE" ] ; then
if [ $(wc -c < "$WDOG_LOG_FILE") -ge 200000 ]; then
#Limit the logfile, just keep the last 100 lines
echo "$(tail -100 $WDOG_LOG_FILE)" > $WDOG_LOG_FILE
fi
fi
# Rotating temp logs
TEMP_LOG_FILE="/home/m1/6_autotemplog"
if [ -e "$TEMP_LOG_FILE" ] ; then
if [ $(wc -c < "$TEMP_LOG_FILE") -ge 200000 ]; then
#Limit the logfile, just keep the last 100 lines
echo "$(tail -100 $TEMP_LOG_FILE)" > $TEMP_LOG_FILE
fi
fi
# Rotating watchdog screenlog
WDOG_SCREEN_LOG_FILE="/home/m1/nvoc_logs/watchdog-screenlog.0"
if [ -e "$WDOG_SCREEN_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$(tail -n 2k $WDOG_SCREEN_LOG_FILE)" > $WDOG_SCREEN_LOG_FILE
fi
# Rotating temp control screenlog
TEMP_SCREEN_LOG_FILE="/home/m1/nvoc_logs/tempcontrol-screenlog.0"
if [ -e "$TEMP_SCREEN_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$(tail -n 2k $TEMP_SCREEN_LOG_FILE)" > $TEMP_SCREEN_LOG_FILE
fi
# Rotating screenlog
MINER_LOG_FILE="/home/m1/nvoc_logs/screenlog.0"
if [ -e "$MINER_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$(tail -n 2k $MINER_LOG_FILE)" > $MINER_LOG_FILE
fi
# Rotating wtm auto switch logs
WTM_LOG_FILE="/home/m1/nvoc_logs/8_wtmautoswitchlog"
if [ -e "$WTM_LOG_FILE" ] ; then
#Limit the logfile, just keep the last 2k
echo "$(tail -n 2k $WTM_LOG_FILE)" > $WTM_LOG_FILE
fi
echo "$(date) - Rotate again in $TIMEIN Hours"
sleep $TIMEOUT
done