
Comply with ZDNET: Add us as a preferred source on Google.
ZDNET’s key takeaways
- In case your Linux system locks up, it’d want rebooting.
- With the assistance of a small utility, this may be automated.
- Watchdog is straightforward to put in and free to make use of.
I’ve a number of Linux programs in my residence lab; some are desktops and a few are servers. Ninety-nine p.c of the time, these machines work flawlessly. When that one p.c occurs, any machine that goes south wants assist.
A technique to assist is thru a small software program bundle referred to as Watchdog. This software program runs varied checks to find out whether or not the {hardware} has “locked up.” If it detects that it has occurred, it is going to reboot the machine.
Additionally: 6 reasons a minimal Linux install might be the smartest move you make
There are two sorts of Watchdogs: software program and {hardware}. The {hardware} Watchdog is rather more dependable, but it surely requires specialised {hardware} to work. The software program Watchdog is not fairly as dependable, but it surely works on most Linux programs.
How Watchdog works
A kernel module (softdog), together with the Watchdog service, watches the system with a countdown timer.
- A digital machine is created (/dev/watchdog).
- If the digital machine is “kicked” by a course of, the timer resets.
- If the digital machine is not “kicked” by a course of, Watchdog reboots the system.
It is easy in principle, however the underpinnings are rather more sophisticated. Happily, as a consumer, you do not have to dig too deeply to get the gist of Watchdog.
Additionally: The first 8 Linux commands every new user should learn
Though Watchdog may be important for servers (particularly these that do not have a monitor, keyboard, or mouse related), it may also be helpful for desktops. For instance, say you might want to log right into a Linux machine on your own home community from work. If that machine locks up, you will not have the ability to entry it. If that machine has Watchdog retaining tabs on it, it will reboot, and you’ll entry it.
This may be very helpful.
You may suppose Watchdog is tough to arrange, however you will be shocked that it isn’t that a lot of a problem, even should you’re just starting out with Linux.
Let me present you the way it’s accomplished.
Tips on how to set up Watchdog
What you will want: I will display this on a machine operating Ubuntu 24.04. Watchdog is present in the usual Ubuntu repositories (in addition to the Fedora normal repositories). For Arch customers, you must use yay to put in this software program. You may additionally want a consumer with sudo privileges.
The very first thing to do is set up Watchdog, which may be accomplished with the command:
Present extra
sudo apt-get set up watchdog -y
In the event you’re utilizing a Fedora-based machine, the command is:
sudo dnf set up watchdog -y
For Arch, it is:
yay -S watchdog
With Watchdog put in, you then need to load the softdog kernel module, which is completed with:
Present extra
sudo modprobe softdog
Confirm the module has loaded with:
lsmod | grabbed the softdog
In the event you see softdog listed, then it is efficiently loaded.
Additionally: The best Linux laptops in 2026: Expert tested for students, hobbyists, and pros
Examine to ensure the machine node exists with:
ls -la /dev/watchdog
You may additionally must have the Watchdog kernel module loaded at boot. In the event you do not do that, the service will not be operating after a reboot (so it will not be watching the system). That is accomplished with:
Present extra
Be sure that to sort this command appropriately.
Jack WallenZDNET
You are now able to configure Watchdog.
Tips on how to configure Watchdog
With Watchdog operating, you will need to ensure that the configuration file is ready up such that it will truly do what it is imagined to do when it ought to. That is accomplished by the use of a configuration file. Open that file with the command:
sudo nano /and many others/watchdog.conf
In that file, search for the next traces (they don’t seem to be discovered consecutively within the file):
# watchdog-device = /dev/watchdog
# interval = 1
# watchdog-timeout = 20 # Time in seconds earlier than reboot
# realtime = sure
# precedence = 1
# max-load-1 = 24
# max-load-5 = 18
# max-load-15 = 12
# min-memory = 1
What you might want to do is take away the # and the house earlier than every line. Notice: In the event you do not see the watchdog-timeout = 20 line, manually add it.
Save and shut the file.
You may then want to begin and allow the service with the command:
sudo systemctl allow –now watchdog
Watchdog is now operating within the background and can do its factor, ought to one thing go awry.
Additionally: You can use Linux 7.0 on these 7 distros today – here’s what to expect
If you wish to take a look at whether or not or not Watchdog is working, you possibly can manually trigger a kernel panic with the next three instructions:
sudo sysctl -w kernel.sysrq=1
sudo su –
echo c > /proc/sysrq-trigger
The system will change into unresponsive, and Watchdog ought to reboot it.
The {hardware} technique
In the event you occur to have a {hardware} watchdog, systemd may be configured to kick it and enact a reboot. Here is the way you configure this.
Open the systemd config file with:
sudo nano /and many others/systemd/system.conf
Find the next traces:
#RuntimeWatchdogSec=0
#RebootWatchdogSec=10min
#WatchdogDevice=
Change these traces to:
RuntimeWatchdogSec=30
RebootWatchdogSec=10min
WatchdogDevice=/dev/watchdog
Save and shut the file.
Additionally: My 5 go-to Linux commands for troubleshooting – and how I use them
Restart the systemd daemon with:
sudo systemctl daemon-reload
And there you have got it. You now have a service watching your system and can reboot it, ought to issues go south.
