Browse Source

[Improve][rootfs][crontab]

2021.03.25 / Folus Wen

Actions:
1. Auto clear log implement if  flash capacity less than 75%.

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 4 years ago
parent
commit
9f6704b4af

+ 14 - 0
EVSE/rootfs/usr/bin/check_log_storage.sh

@@ -0,0 +1,14 @@
+#!/bin/sh
+idx_start=6
+idx_end=18
+percent=`df -h /Storage|grep Storage|awk '{print $5}'|cut -d '%' -f 1`
+
+while [ $percent -ge 80 -a $idx_start -ge 1 ]
+do
+        echo $idx_start   $idx_end
+        /usr/bin/run_log_clear.sh $idx_start $idx_end
+        percent=`df -h /Storage|grep Storage|awk '{print $5}'|cut -d '%' -f 1`
+        idx_start=$(( idx_start-1 ))
+        idx_end=$(( idx_end-1 ))
+	sync
+done

+ 1 - 1
EVSE/rootfs/usr/bin/run_log_clear.sh

@@ -20,7 +20,7 @@ else
                 now=$(( `date +%s`-(($idx*30)*86400)))
                 target=`date -D '%s' +%Y.%m -d "$now"`
                 echo $target
-                `/bin/rm -f /Storage/System/[$target\]*`
+                `/bin/rm -f /Storage/SystemLog/[$target\]*`
                 `/bin/rm -f /Storage/OCPP/[$target\]*`
         done
 

+ 1 - 1
EVSE/rootfs/var/spool/cron/crontabs/root

@@ -23,4 +23,4 @@
 0 0 * * * cat "" > /Storage/SystemLog/check_tmate.log
 #* * * * * /usr/bin/check_tmate.sh >> /Storage/SystemLog/check_tmate.log 2>&1
 0 * * * * /sbin/logrotate /etc/logrotate.conf
-0 1 * * * /usr/bin/run_log_clear.sh 6 18
+0 1 * * * /usr/bin/check_log_storage.sh