I Set Up This Linux 'watchdog' And Now My System Auto-reboots When It Locks Up

Trending 1 hour ago
3d rendering of a futuristic mechanical canine stuffed artifact successful a acheronian achromatic inheritance pinch a effect of roar for nan 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 nan thief of a mini application, this tin beryllium automated.
  • Watchdog is easy to instal and free 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 nan time, those machines activity flawlessly. When that 1 percent happens, immoderate instrumentality that goes southbound needs help.

One measurement of helping is via a mini package package called Watchdog. This portion of package runs various checks to spot if nan hardware has "locked up." If it detects that it has happened, it will reboot nan machine.

Also: 6 reasons a minimal Linux instal mightiness beryllium nan smartest move you make

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

How Watchdog works

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

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

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

Also: The first 8 Linux commands each caller personification should learn

Although Watchdog tin beryllium basal for servers (especially those that don't person a monitor, keyboard, aliases rodent connected), it tin besides beryllium useful for desktops. For example, opportunity 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 very handy.

You mightiness deliberation Watchdog is difficult to group up, but you'll beryllium amazed that it's not that overmuch of a challenge, moreover if you're just starting retired pinch Linux.

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

Let maine show you really 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 nan modular Ubuntu repositories (as good arsenic nan Fedora modular repositories). For Arch users, you person to usage yay to instal this software. You'll besides request a personification pinch sudo privileges.

The first point to do is instal Watchdog, which tin beryllium done pinch nan command:

Show more

sudo apt-get instal watchdog -y

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

sudo dnf instal watchdog -y

For Arch, it's:

yay -S watchdog

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

Show more

sudo modprobe softdog

Verify nan 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 make judge nan instrumentality node exists with:

ls -la /dev/watchdog

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

Show more

Watchdog

Make judge to type this bid correctly.

Jack Wallen\ZDNET

You're now fresh to configure Watchdog.

How to configure Watchdog

With Watchdog running, you'll want to make judge nan configuration record is group up specified that it'll really do what it's expected to do erstwhile it should. This is done by measurement of a configuration file. Open that record pinch nan command:

sudo nano /etc/watchdog.conf

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

# watchdog-device = /dev/watchdog

# interval = 1

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

# realtime = yes

# privilege = 1

# max-load-1 = 24

# max-load-5 = 18

# max-load-15 = 12

# min-memory = 1

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

Save and adjacent nan file.

You'll past request to commencement and alteration nan work pinch nan command:

sudo systemctl alteration --now watchdog

Watchdog is now moving successful nan inheritance and will do its thing, should thing spell awry.

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

If you want to trial whether aliases not Watchdog is working, you tin manually origin a kernel panic pinch nan pursuing 3 commands:

sudo sysctl -w kernel.sysrq=1

sudo su -

echo c > /proc/sysrq-trigger

The strategy will 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 really you configure this.

Open nan systemd config record with:

sudo nano /etc/systemd/system.conf

Locate nan pursuing lines:

#RuntimeWatchdogSec=0

#RebootWatchdogSec=10min

#WatchdogDevice=

Change those lines to:

RuntimeWatchdogSec=30

RebootWatchdogSec=10min

WatchdogDevice=/dev/watchdog

Save and adjacent nan file.

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

Restart nan systemd daemon with:

sudo systemctl daemon-reload

And location you person it. You now person a work watching your strategy and will reboot it, should things spell south.

More