Follow ZDNET: Add us as a favorite source On Google.
ZDNET Key Takeaways
- If your Linux system locks up, it may need to reboot.
- This can be automated with the help of a small application.
- Watchdog is easy to install and free to use.
I have several Linux systems connected to my home lab; Some of them are desktop, and some of them are server. Ninety-nine percent of the time, those machines work flawlessly. When that one percent happens, any machine going south needs help.
One way to help is through a small software package called Watchdog. This part of the software runs various checks to see if the hardware is “locked up.” If it detects that this has happened, it will reboot the machine.
Too: 6 reasons why a minimal Linux install might be the smartest move you’ve made
There are two types of watchdogs: software and hardware. Hardware Watchdog is more reliable, but it requires specialized hardware to work. Software Watchdog is not as reliable, but it works on most Linux systems.
How does a watchdog work?
A kernel module (Softdog), together with the watchdog service, watches the system with a countdown timer.
- A virtual device has been created (/dev/watchDog).
- If the virtual device is “kicked” by a process, the timer is reset.
- If the virtual device is not “kicked” by any process, the watchdog reboots the system.
It’s simple in theory, but its foundation is much more complex. Luckily, as a user, you don’t have to dig too deep to find out the essence of Watchdog.
Also: The First 8 Linux Commands Every New User Should Learn
Although Watchdog may be necessary for servers (especially those that do not have a monitor, keyboard, or mouse connected), it can also be useful for desktops. For example, let’s say you need to log into a Linux machine on your home network from work. If that machine is locked, you will not be able to access it. If that machine is monitored by Watchdog, it will reboot, and you will be able to access it.
This can be very useful.
You might think that setting up Watchdog is hard, but you’ll be surprised that it’s not that big of a challenge, even if you’re just starting out with Linux.
Also: My 5 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 will need to use yay to install this software. You will also need a user with sudo privileges.
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 is:
wow -s sentinel
After Watchdog is installed, you need to load the Softdog kernel module, which is done with:
show more
sudo modprobe softdog
Verify that the module is loaded with:
LSMOD | Grape Softdog
If you see Softdog listed, it has loaded successfully.
Also: Best Linux Laptops in 2026: Expert-Tested for Students, Hobbyists, and Professionals
Check to make sure the device node exists with:
ls -la /dev/watchdog
You also need to load the watchdog kernel module on boot. If you don’t do this, the service will not run after a reboot (so it won’t be able to see the system). This is done with:
show more
Make sure this command is typed correctly.
Jack WallenZDNET
You are now ready to configure Watchdog.
How to configure watchdog
With watchdog running, you’ll want to make sure that the configuration file is set up such that it will actually do what it’s supposed to do. This is done through 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
# real time = yes
# priority = 1
# max-load-1 = 24
# max-load-5 = 18
# max-load-15 = 12
# min-memory = 1
You need to remove the # and spaces before each line. Note: If you don’t see watchdog-timeout=20 line, add it manually.
Save and close the file.
You will 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 job if something goes wrong.
Too: You Can Use Linux 7.0 on These 7 Distros Today – Here’s What to Expect
If you want to check whether the 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.
hardware method
If you have a hardware watchdog, systemd can be configured to kick it in and enforce a reboot. Here’s how you configure it.
Open the systemd config file with:
sudo nano /etc/systemd/system.conf
Find the following lines:
#RuntimeWatchDogSec=0
#rebootwatchdogssec=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 upgrading RAM isn’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 that is monitoring your system and will reboot it if things go wrong.
