Cron based NTPD watchdog
-
I hacked up this small script to restart NTPD if it is found stopped.
/* $Id$ */ /* watchdog_ntpd written for pfSense (http://www.pfSense.com) Shahid Sheikh This is a quick hack to check if ntpd is running. If not, this restarts it. */ require_once("service-utils.inc"); require_once("system.inc"); if (!(is_service_running("ntpd"))) { log_error("NTPD was found dead."); system_ntp_configure(true); } ?>
saved it as /etc/watchdog_ntpd.
chmod +x /etc/watchdog_ntpd
Added to the config.xml in the <cron>…</cron> section:
<minute>0</minute> <hour>*/3</hour> <mday>*</mday> <month>*</month> <wday>*</wday> <who>root</who> <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.
Shahid
-
"principle of cause and effect"
If nobody here which change the cause, we have to fight with the effect.Thanks for the script.
Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.