I set up this Linux 'Watchdog' and now my system auto-reboots when it locks up

1 hour ago 5
3d rendering of a futuristic mechanical canine  stuffed artifact  successful  a acheronian  achromatic  inheritance  with a effect   of roar  for the intent  of advertisement and commercialized  use
AssasinatorCzar via iStock / Getty Images Plus

Follow ZDNET: Add america arsenic a preferred source connected Google.


ZDNET cardinal takeaways

  • If your Linux strategy locks up, it mightiness request rebooting.
  • With the assistance of a tiny application, this tin beryllium automated.
  • Watchdog is casual to instal and escaped to use.

I person respective Linux systems connected to my location lab; immoderate of them are desktops, and immoderate of them are servers. Ninety-nine percent of the time, those machines enactment flawlessly. When that 1 percent happens, immoderate instrumentality that goes southbound needs help.

One mode of helping is via a tiny bundle bundle called Watchdog. This portion of bundle runs assorted checks to spot if the hardware has "locked up." If it detects that it has happened, it volition reboot the machine.

Also: 6 reasons a minimal Linux instal mightiness beryllium the smartest determination you make

There are 2 types of Watchdogs: bundle and hardware. The hardware Watchdog is overmuch much reliable, but it requires specialty hardware for it to work. The bundle Watchdog isn't rather arsenic reliable, but it works connected astir Linux systems.

How Watchdog works

A kernel module (softdog), successful conjunction with the Watchdog service, watches the strategy with a countdown timer.

  • A virtual instrumentality is created (/dev/watchdog).
  • If the virtual instrumentality is "kicked" by a process, the timer resets.
  • If the virtual instrumentality isn't "kicked" by a process, Watchdog reboots the system.

It's elemental successful theory, but the underpinnings are overmuch much complicated. Fortunately, arsenic a user, you don't person to excavation excessively profoundly to get the gist of Watchdog.

Also: The archetypal 8 Linux commands each caller idiosyncratic should learn

Although Watchdog tin beryllium indispensable for servers (especially those that don't person a monitor, keyboard, oregon rodent connected), it tin besides beryllium utile for desktops. For example, accidental you request to log into a Linux instrumentality connected your location web from work. If that instrumentality locks up, you won't beryllium capable to entree it. If that instrumentality has Watchdog keeping tabs connected it, it'll reboot, and you'll beryllium capable to entree it.

This tin beryllium precise handy.

You mightiness deliberation Watchdog is hard to acceptable up, but you'll beryllium amazed that it's not that overmuch of a challenge, adjacent if you're just starting retired with Linux.

Also: My 5 go-to Linux commands for troubleshooting - and however I usage them

Let maine amusement you however it's done.

How to instal Watchdog

What you'll need: I'm going to show this connected a instrumentality moving Ubuntu 24.04. Watchdog is recovered successful the modular Ubuntu repositories (as good arsenic the Fedora modular repositories). For Arch users, you person to usage yay to instal this software. You'll besides request a idiosyncratic with sudo privileges.

The archetypal happening to bash is instal Watchdog, which tin beryllium done with the command:

Show more

sudo apt-get instal watchdog -y

If you're utilizing a Fedora-based machine, the bid is:

sudo dnf instal watchdog -y

For Arch, it's:

yay -S watchdog

With Watchdog installed, you past person to load the softdog kernel module, which is done with:

Show more

sudo modprobe softdog

Verify the module has loaded with:

lsmod | grep softdog

If you spot softdog listed, past it's successfully loaded.

Also: The champion Linux laptops successful 2026: Expert tested for students, hobbyists, and pros

Check to marque definite the instrumentality node exists with:

ls -la /dev/watchdog

You'll besides request to person the Watchdog kernel module loaded astatine boot. If you don't bash this, the work won't beryllium moving aft a reboot (so it won't beryllium watching the system). This is done with:

Show more

Watchdog

Make definite to benignant this bid correctly.

Jack Wallen\ZDNET

You're present acceptable to configure Watchdog.

How to configure Watchdog

With Watchdog running, you'll privation to marque definite the configuration record is acceptable up specified that it'll really bash what it's expected to bash erstwhile it should. This is done by mode of a configuration file. Open that record with the command:

sudo nano /etc/watchdog.conf

In that file, look for the pursuing lines (they are not recovered consecutively successful the file):

# watchdog-device = /dev/watchdog

# interval = 1

# watchdog-timeout = 20 # Time successful seconds earlier reboot

# realtime = yes

# precedence = 1

# max-load-1 = 24

# max-load-5 = 18

# max-load-15 = 12

# min-memory = 1

What you request to bash is region the # and the abstraction earlier each line. Note: If you don't spot the watchdog-timeout = 20 line, manually adhd it.

Save and adjacent the file.

You'll past request to commencement and alteration the work with the command:

sudo systemctl alteration --now watchdog

Watchdog is present moving successful the inheritance and volition bash its thing, should thing spell awry.

Also: You tin usage Linux 7.0 connected these 7 distros contiguous - here's what to expect

If you privation to trial whether oregon not Watchdog is working, you tin manually origin a kernel panic with the pursuing 3 commands:

sudo sysctl -w kernel.sysrq=1

sudo su -

echo c > /proc/sysrq-trigger

The strategy volition go unresponsive, and Watchdog should reboot it.

The hardware method

If you hap to person a hardware watchdog, systemd tin beryllium configured to footwear it and enact a reboot. Here's however you configure this.

Open the systemd config record with:

sudo nano /etc/systemd/system.conf

Locate the pursuing lines:

#RuntimeWatchdogSec=0

#RebootWatchdogSec=10min

#WatchdogDevice=

Change those lines to:

RuntimeWatchdogSec=30

RebootWatchdogSec=10min

WatchdogDevice=/dev/watchdog

Save and adjacent the file.

Also: My proven mode to velocity up Linux erstwhile RAM upgrades aren't worthy it (and it's escaped to do)

Restart the systemd daemon with:

sudo systemctl daemon-reload

And determination you person it. You present person a work watching your strategy and volition reboot it, should things spell south.

Read Entire Article