Cron based NTPD watchdog

  • I hacked up this small script to restart NTPD if it is found stopped.

    /* $Id$ */
        written for pfSense (
        Shahid Sheikh
        This is a quick hack to check if ntpd is running.
        If not, this restarts it.
    if (!(is_service_running("ntpd"))) {
        log_error("NTPD was found dead.");

    saved it as /etc/watchdog_ntpd.

    chmod +x /etc/watchdog_ntpd

    Added to the config.xml in the <cron>…</cron> section:

                            <command></command>/usr/bin/nice -n20 /etc/watchdog_ntpd 

    Using the Cron package makes managing the Cron jobs easier. I prefer to use it instead of tinkering with the xml file.

    Adjust the frequency of running the check as needed. I have mine set to every 3 hours.


  • "principle of cause and effect"
    If nobody here which change the cause, we have to fight with the effect.

    Thanks for the script.

Log in to reply