NTP boot watchdog script

  • ATTENTION! You'll notice a Prefix dropdown when you create a thread. If your post applies to one of the topics listed, please use that Prefix for your post. When browsing the thread list you can use the Prefix to filter the view.
  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

Jack Yaz

Part of the Furniture
Do you find that NTP will often taken longer than 5 minutes to sync, causing some addons to fail to start? If so, please read on for a workaround!

NTP "aggressive" syncing on boot while I thrash out a proper fix
Create /jffs/scripts/ntpbootwatchdog.sh
Code:
#!/bin/sh
if [ "$(nvram get ntp_ready)" -eq 1 ]; then
    /usr/bin/logger -st "ntpbootwatchdog" "NTP is synced, exiting"
else
    /usr/bin/logger -st "ntpbootwatchdog" "NTP boot watchdog started..."
    ntptimer=0
    while [ "$(nvram get ntp_ready)" -eq 0 ] && [ "$ntptimer" -lt 600 ]; do
        if [ "$ntptimer" -ne 0 ]; then
            /usr/bin/logger -st "ntpbootwatchdog" "Still waiting for NTP to sync..."
        fi
        killall ntp
        killall ntpd
        service restart_ntpd
        ntptimer=$((ntptimer+30))
        sleep 30
    done
    
    if [ "$ntptimer" -ge 600 ]; then
        /usr/bin/logger -st "ntpbootwatchdog" "NTP failed to sync after 10 minutes - please check immediately!"
        exit 1
    else
        /usr/bin/logger -st "ntpbootwatchdog" "NTP has synced!"
    fi
fi

Create or edit /jffs/scripts/init-start
Code:
#!/bin/sh
sh /jffs/scripts/ntpbootwatchdog.sh & #make sure NTP starts

Make sure both are executable
Code:
chmod +x /jffs/scripts/ntpbootwatchdog.sh
chmod +x /jffs/scripts/init-start
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top