Linux Watchdog Daemon - Installation

Back to PSC's home page
Back to Watchdog


Installation

In most Linux distributions you can install from the package manager. For example on Ubuntu/Debian-based systems:

apt-get install watchdog

To fully benefit from the watchdog capability and reboot a hung kernel, etc, then it is necessary to have a hardware timer linked to this. The driver module is best added to /etc/default/watchdog by editing the line watchdog_module="none" as that is loaded on demand, and gets round the buggy behaviour of systemd not loading explicitly listed modules that are blacklisted for auto-load.

Some general suggestions for modules to get the hardware timer to work are:

  • If you are using a server style of machine with lights-out management almost certainly it will support IPMI, so try the impi_watchdog driver (part of the the ipmitool package). NOTE: You might need to enable this feature in the lights-out manager first.
  • For general machines using Intel CPUs then the iTCO_wdt module will probably work.
  • For Raspberry Pi then you can try loading the bcm2835_wdt module, but it might be better to try adding dtparam=watchdog=on to your /boot/config.txt file. NOTE: In this case you must change the watchdog-timeout value in watchdog.conf to 15 seconds as that hardware does not support the default 60 seconds.
  • Another way of identifying any hardware watchdog options is to use the 'lshw' command (as root/sudo) to find the chip set(s) used, then to search for drivers or documentation for those chips that allow you to establish if they have watchdog timers, and if so what driver should work. Some I have found on various PCs of a few years ago are the w83627hf_wdt and it87_wdt modules. You can try modprob to load them and then look in syslog and/or use lsmod to see if they are loaded. However, you need to test they are working to be sure as the hardware detection aspect of the module is not very strict.
  • If all else fails, consider loading the softdog module to emulate the hardware. It is not nearly as good, but better than nothing.

  • NOTE: To replace the daemon with any special build you should stop it first, as described below. It is also a good idea to rename the original version and keep it so you can revert if anything goes wrong when testing.

    [top of page]

    Starting and Stopping

    Normally the daemons are started and stopped by the scripts such as /etc/init.d/watchdog but the usual command to do this (as root, or using sudo) is:

    service watchdog start
    service watchdog stop

    However, this script is actually swapping execution of 'watchdog' and 'wd_keepalive' in a similar manner to the system starting and stopping.

    NOTE: This swapping behaviour is essential in the unlikely case that your kernel was compiled with the option CONFIG_WATCHDOG_NOWAYOUT, or a WDT module was loaded with that option, as then you cannot turn the watchdog off after starting it, so you always need to be running something to stop a reboot. Swapping daemons is then a way of allowing you to replace the binary and/or change the configuration file safely.

    The daemons are actually stopped by sending the signal SIGTERM (usually 15) to them which is the "polite" way of requesting a program to terminate. They trap this signal and when detected break from the main polling loop and exit cleanly (closing the watchdog hardware). Thus it can take up to the configured polling time interval for this to stop the process.

    NOTE: If you kill the daemon by another signal, such as sending SIGKILL (usually 9, a non-ignorable signal) or SIGINT (usually 2, typically from Ctrl+C when running in the foreground) then it will not close the watchdog device and you can expect a hardware reboot to occur shortly unless the daemon is restarted!

    Typically to really stop the daemon (and not just run wd_keepalive in its place) you can do this using pkill (again as root or using sudo):

    pkill watchdog

    By default pkill sends SIGTERM, which is what you normally want. You can start the daemon from the command line for testing, and if you want to see the output of the daemon and any child test/repair process in real-time (rather than looking at log files such as syslog) you can use the foreground option, for example:

    watchdog --foreground

    This will stop it becoming a background daemon and so it will run like a normal foreground process. To stop it open another terminal window and send it SIGTERM using pkill (i.e. don't use Ctrl+C).
    [top of page]

    Last Updated on 8-Mar-2026 by Paul Crawford
    Copyright (c) 2014-26 by Paul S. Crawford. All rights reserved.
    Email psc(at)sat(dot)dundee(dot)ac(dot)uk
    Absolutely no warranty, use this information at your own risk.