From 12fb2678d1e8aca512523ff57e80117d9cd4d2a5 Mon Sep 17 00:00:00 2001 From: robin_ren <58209006+robin-debug@users.noreply.github.com> Date: Tue, 11 Mar 2025 07:18:15 +0000 Subject: [PATCH] check sdcard file,to fix system time --- general/overlay/etc/rc.local | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/general/overlay/etc/rc.local b/general/overlay/etc/rc.local index 1426ecbb..e101e8e3 100755 --- a/general/overlay/etc/rc.local +++ b/general/overlay/etc/rc.local @@ -11,4 +11,18 @@ # # By default this script does nothing. +target_dir="/mnt/mmcblk0p1" +[ ! -d "$target_dir" ] && echo "not find" && exit 1 + +latest_time=$(find "$target_dir" -exec stat -c '%Y' {} \; 2>/dev/null | sort -nr | head -1) +[ -z "$latest_time" ] && echo "no sub dir" && exit 0 +echo latest_time $latest_time + +current_time=$(date +%s) +echo current_time $current_time + +if [ "$latest_time" -gt "$current_time" ]; then + date -s "@$latest_time" >/dev/null && echo "ok" || echo "fail" +fi + exit 0