
Follow ZDNET: Add us as a preferred source on Google.
ZDNET key takeaways
- If your Linux system locks up, it might need rebooting.
- With the help of a small application, this can be automated.
- Watchdog is easy to install and free to use.
I have several Linux systems connected to my home lab; some of them are desktops, and some of them are servers. Ninety-nine percent of the time, those machines work flawlessly. When that one percent happens, any machine that goes south needs help.
One way of helping is via a small software package called Watchdog. This piece of software runs various checks to see if the hardware has “locked up.” If it detects that it has happened, it will reboot the machine.
Also: 6 reasons a minimal Linux install might be the smartest move you make
There are two types of Watchdogs: software and hardware. The hardware Watchdog is much more reliable, but it requires specialty hardware for it to work. The software Watchdog isn’t quite as reliable, but it works on most Linux systems.
How Watchdog works
A kernel module (softdog), in conjunction with the Watchdog service, watches the system with a countdown timer.
- A virtual device is created (/dev/watchdog).
- If the virtual device is “kicked” by a process, the timer resets.
- If the virtual device isn’t “kicked” by a process, Watchdog reboots the system.
It’s simple in theory, but the underpinnings are much more complicated. Fortunately, as a user, you don’t have to dig too deeply to get the gist of Watchdog.
Also: The first 8 Linux commands every new user should learn
Although Watchdog can be essential for servers (especially those that don’t have a monitor, keyboard, or mouse connected), it can also be useful for desktops. For example, say you need to log into a Linux machine on your home network from work. If that machine locks up, you won’t be able to access it. If that machine has Watchdog keeping tabs on it, it’ll reboot, and you’ll be able to access it.
This can be very handy.
You might think Watchdog is hard to set up, but you’ll be surprised that it’s not that much of a challenge, even if you’re just starting out with Linux.
Also: My 5 go-to Linux commands for troubleshooting – and how I use them
Let me show you how it’s done.
How to install Watchdog
What you’ll need: I’m going to demonstrate this on a machine running Ubuntu 24.04. Watchdog is found in the standard Ubuntu repositories (as well as the Fedora standard repositories). For Arch users, you have to use yay to install this software. You’ll also need a user with sudo privileges.
The first thing to do is install Watchdog, which can be done with the command:
sudo apt-get install watchdog -y
If you’re using a Fedora-based machine, the command is:
sudo dnf install watchdog -y
For Arch, it’s:
yay -S watchdog
With Watchdog installed, you then have to load the softdog kernel module, which is done with:
sudo modprobe softdog
Verify the module has loaded with:
lsmod | grep softdog
If you see softdog listed, then it’s successfully loaded.
Also: The best Linux laptops in 2026: Expert tested for students, hobbyists, and pros
Check to make sure the device node exists with:
ls -la /dev/watchdog
You’ll also need to have the Watchdog kernel module loaded at boot. If you don’t do this, the service won’t be running after a reboot (so it won’t be watching the system). This is done with:
Make sure to type this command correctly.
Jack WallenZDNET
You’re now ready to configure Watchdog.
How to configure Watchdog
With Watchdog running, you’ll want to make sure the configuration file is set up such that it’ll actually do what it’s supposed to do when it should. This is done by way of a configuration file. Open that file with the command:
sudo nano /etc/watchdog.conf
In that file, look for the following lines (they are not found consecutively in the file):
# watchdog-device = /dev/watchdog
# interval = 1
# watchdog-timeout = 20 # Time in seconds before reboot
# realtime = yes
# priority = 1
# max-load-1 = 24
# max-load-5 = 18
# max-load-15 = 12
# min-memory = 1
What you need to do is remove the # and the space before each line. Note: If you don’t see the watchdog-timeout = 20 line, manually add it.
Save and close the file.
You’ll then need to start and enable the service with the command:
sudo systemctl enable –now watchdog
Watchdog is now running in the background and will do its thing, should something go awry.
Also: You can use Linux 7.0 on these 7 distros today – here’s what to expect
If you want to test whether or not Watchdog is working, you can manually cause a kernel panic with the following three commands:
sudo sysctl -w kernel.sysrq=1
sudo su –
echo c > /proc/sysrq-trigger
The system will become unresponsive, and Watchdog should reboot it.
The hardware method
If you happen to have a hardware watchdog, systemd can be configured to kick it and enact a reboot. Here’s how you configure this.
Open the systemd config file with:
sudo nano /etc/systemd/system.conf
Locate the following lines:
#RuntimeWatchdogSec=0
#RebootWatchdogSec=10min
#WatchdogDevice=
Change those lines to:
RuntimeWatchdogSec=30
RebootWatchdogSec=10min
WatchdogDevice=/dev/watchdog
Save and close the file.
Also: My proven way to speed up Linux when RAM upgrades aren’t worth it (and it’s free to do)
Restart the systemd daemon with:
sudo systemctl daemon-reload
And there you have it. You now have a service watching your system and will reboot it, should things go south.