Explorar el Código

add function to delete logs older than 5 boots

Alfonso Gamboa hace 3 años
padre
commit
35d106a5c5
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      SD_ROOT/wz_mini/etc/init.d/wz_user.sh

+ 10 - 0
SD_ROOT/wz_mini/etc/init.d/wz_user.sh

@@ -162,6 +162,15 @@ dmesg > $DMESG_LOG.log 2>&1
 
 }
 
+trim_logs() {
+
+echo "Deleting logs older than 5 boots..."
+
+find /opt/wz_mini/log -name '*log*' | while read file; do
+  [ "${file#/opt/wz_mini/log/*log.}" -gt 5 ] && rm -v "$file"
+done
+
+}
 
 first_run_check
 wait_sdroot
@@ -559,6 +568,7 @@ touch /opt/wz_mini/tmp/.wz_user_firstrun
 pkill -f dumpload #Kill dumpload so it won't waste cpu or ram gathering cores when something crashes
 sysctl -w kernel.core_pattern='|/bin/false'
 dmesg_log
+trim_logs
 sync;echo 3 > /proc/sys/vm/drop_caches