Is it possible to activate the watchdog on any Linux machine?
On an Orange Pi Zero running a Raspbian server, it's possible to use the watchdog very easily just by running the command echo 1 > /dev/watchdog
as root. The idea is that the system will certainly reboot after some time that this command is executed, so I need to keep repeating this command in a regular interval of time to keep the system on. We can implement a watchdog using cron
as root and making it execute the following script on boot:
#!/bin/bash
while [ true ]; do
echo 1 > /dev/watchdog
sleep 5
done
This script works fine on the Orange Pi Zero... However, on my desktop computer running the Ubuntu 18.04 the command echo 1 > /dev/watchdog
doesn't work at all. Is it possible to activate the watchdog on any device running Linux? Or is it one parameter that needs to be specified on the Kernel while it's compiled?
linux-kernel raspbian watchdog
add a comment |
On an Orange Pi Zero running a Raspbian server, it's possible to use the watchdog very easily just by running the command echo 1 > /dev/watchdog
as root. The idea is that the system will certainly reboot after some time that this command is executed, so I need to keep repeating this command in a regular interval of time to keep the system on. We can implement a watchdog using cron
as root and making it execute the following script on boot:
#!/bin/bash
while [ true ]; do
echo 1 > /dev/watchdog
sleep 5
done
This script works fine on the Orange Pi Zero... However, on my desktop computer running the Ubuntu 18.04 the command echo 1 > /dev/watchdog
doesn't work at all. Is it possible to activate the watchdog on any device running Linux? Or is it one parameter that needs to be specified on the Kernel while it's compiled?
linux-kernel raspbian watchdog
add a comment |
On an Orange Pi Zero running a Raspbian server, it's possible to use the watchdog very easily just by running the command echo 1 > /dev/watchdog
as root. The idea is that the system will certainly reboot after some time that this command is executed, so I need to keep repeating this command in a regular interval of time to keep the system on. We can implement a watchdog using cron
as root and making it execute the following script on boot:
#!/bin/bash
while [ true ]; do
echo 1 > /dev/watchdog
sleep 5
done
This script works fine on the Orange Pi Zero... However, on my desktop computer running the Ubuntu 18.04 the command echo 1 > /dev/watchdog
doesn't work at all. Is it possible to activate the watchdog on any device running Linux? Or is it one parameter that needs to be specified on the Kernel while it's compiled?
linux-kernel raspbian watchdog
On an Orange Pi Zero running a Raspbian server, it's possible to use the watchdog very easily just by running the command echo 1 > /dev/watchdog
as root. The idea is that the system will certainly reboot after some time that this command is executed, so I need to keep repeating this command in a regular interval of time to keep the system on. We can implement a watchdog using cron
as root and making it execute the following script on boot:
#!/bin/bash
while [ true ]; do
echo 1 > /dev/watchdog
sleep 5
done
This script works fine on the Orange Pi Zero... However, on my desktop computer running the Ubuntu 18.04 the command echo 1 > /dev/watchdog
doesn't work at all. Is it possible to activate the watchdog on any device running Linux? Or is it one parameter that needs to be specified on the Kernel while it's compiled?
linux-kernel raspbian watchdog
linux-kernel raspbian watchdog
edited 3 hours ago
asked 7 hours ago
Rafael Muynarsk
360515
360515
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There are two types of watchdog; hardware and software. On the Orange Pi the SOC chip provides a hardware watchdog. If initialised then it needs to be pinged every so often, otherwise it performs a board reset.
However not many desktops have hardware watchdogs, so the kernel provides a software version. Now the kernel will try and keep track, and force a reboot. This isn't as good as a hardware watchdog because if the kernel, itself, breaks then nothing will trigger the reset. But it works.
The software watchdog can be initialised by loading the softdog
module
% modprobe softdog
% dmesg | tail -1
[ 120.573945] softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
We can see this has a 60 second timeout by default.
If I then do
% echo > /dev/watchdog
% dmesg | tail -1
[ 154.514976] watchdog: watchdog0: watchdog did not stop!
We can see the watchdog hadn't timed out.
I then leave the machine idle for a minute and on the console I see
[ 214.624112] softdog: Initiating system reboot
and the OS reboots.
Many desktops, laptops and servers include hardware watchdogs, often in their Super-I/O chips, or in their PCH; see the various “wdt” modules in the kernel.
– Stephen Kitt
7 hours ago
@StephenHarris Can I assume that when the commandecho > /dev/watchdog
doesn't work at first it's because there's no hardware watchdog for that device? Or there's still the possibility that I need to activate the hardware watchdog before using it?
– Rafael Muynarsk
7 hours ago
1
If/dev/watchdog
doesn't exist (or isn't a character device) and you know your hardware has a watchdog, then you may need tomodprobe
the relevant hardware driver... Modern distro's will try to load this automatically, but you may have an edge-case. None of my machines have a/dev/watchdog
entry :-(
– Stephen Harris
7 hours ago
1
“Many”, not “all” ;-). My last two personal PCs (2003, 2013) have supportediTCO_wdt
, and all my work PCs for the last decade or so have supported one driver or another, but it isn’t loaded automatically; as you mention, in many cases the relevant module needs to be loaded manually, and sometimes the firmware setup has to be configured appropriately too (and sometimes a jumper must be moved on the main board).
– Stephen Kitt
6 hours ago
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
6 hours ago
|
show 2 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491814%2fis-it-possible-to-activate-the-watchdog-on-any-linux-machine%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are two types of watchdog; hardware and software. On the Orange Pi the SOC chip provides a hardware watchdog. If initialised then it needs to be pinged every so often, otherwise it performs a board reset.
However not many desktops have hardware watchdogs, so the kernel provides a software version. Now the kernel will try and keep track, and force a reboot. This isn't as good as a hardware watchdog because if the kernel, itself, breaks then nothing will trigger the reset. But it works.
The software watchdog can be initialised by loading the softdog
module
% modprobe softdog
% dmesg | tail -1
[ 120.573945] softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
We can see this has a 60 second timeout by default.
If I then do
% echo > /dev/watchdog
% dmesg | tail -1
[ 154.514976] watchdog: watchdog0: watchdog did not stop!
We can see the watchdog hadn't timed out.
I then leave the machine idle for a minute and on the console I see
[ 214.624112] softdog: Initiating system reboot
and the OS reboots.
Many desktops, laptops and servers include hardware watchdogs, often in their Super-I/O chips, or in their PCH; see the various “wdt” modules in the kernel.
– Stephen Kitt
7 hours ago
@StephenHarris Can I assume that when the commandecho > /dev/watchdog
doesn't work at first it's because there's no hardware watchdog for that device? Or there's still the possibility that I need to activate the hardware watchdog before using it?
– Rafael Muynarsk
7 hours ago
1
If/dev/watchdog
doesn't exist (or isn't a character device) and you know your hardware has a watchdog, then you may need tomodprobe
the relevant hardware driver... Modern distro's will try to load this automatically, but you may have an edge-case. None of my machines have a/dev/watchdog
entry :-(
– Stephen Harris
7 hours ago
1
“Many”, not “all” ;-). My last two personal PCs (2003, 2013) have supportediTCO_wdt
, and all my work PCs for the last decade or so have supported one driver or another, but it isn’t loaded automatically; as you mention, in many cases the relevant module needs to be loaded manually, and sometimes the firmware setup has to be configured appropriately too (and sometimes a jumper must be moved on the main board).
– Stephen Kitt
6 hours ago
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
6 hours ago
|
show 2 more comments
There are two types of watchdog; hardware and software. On the Orange Pi the SOC chip provides a hardware watchdog. If initialised then it needs to be pinged every so often, otherwise it performs a board reset.
However not many desktops have hardware watchdogs, so the kernel provides a software version. Now the kernel will try and keep track, and force a reboot. This isn't as good as a hardware watchdog because if the kernel, itself, breaks then nothing will trigger the reset. But it works.
The software watchdog can be initialised by loading the softdog
module
% modprobe softdog
% dmesg | tail -1
[ 120.573945] softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
We can see this has a 60 second timeout by default.
If I then do
% echo > /dev/watchdog
% dmesg | tail -1
[ 154.514976] watchdog: watchdog0: watchdog did not stop!
We can see the watchdog hadn't timed out.
I then leave the machine idle for a minute and on the console I see
[ 214.624112] softdog: Initiating system reboot
and the OS reboots.
Many desktops, laptops and servers include hardware watchdogs, often in their Super-I/O chips, or in their PCH; see the various “wdt” modules in the kernel.
– Stephen Kitt
7 hours ago
@StephenHarris Can I assume that when the commandecho > /dev/watchdog
doesn't work at first it's because there's no hardware watchdog for that device? Or there's still the possibility that I need to activate the hardware watchdog before using it?
– Rafael Muynarsk
7 hours ago
1
If/dev/watchdog
doesn't exist (or isn't a character device) and you know your hardware has a watchdog, then you may need tomodprobe
the relevant hardware driver... Modern distro's will try to load this automatically, but you may have an edge-case. None of my machines have a/dev/watchdog
entry :-(
– Stephen Harris
7 hours ago
1
“Many”, not “all” ;-). My last two personal PCs (2003, 2013) have supportediTCO_wdt
, and all my work PCs for the last decade or so have supported one driver or another, but it isn’t loaded automatically; as you mention, in many cases the relevant module needs to be loaded manually, and sometimes the firmware setup has to be configured appropriately too (and sometimes a jumper must be moved on the main board).
– Stephen Kitt
6 hours ago
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
6 hours ago
|
show 2 more comments
There are two types of watchdog; hardware and software. On the Orange Pi the SOC chip provides a hardware watchdog. If initialised then it needs to be pinged every so often, otherwise it performs a board reset.
However not many desktops have hardware watchdogs, so the kernel provides a software version. Now the kernel will try and keep track, and force a reboot. This isn't as good as a hardware watchdog because if the kernel, itself, breaks then nothing will trigger the reset. But it works.
The software watchdog can be initialised by loading the softdog
module
% modprobe softdog
% dmesg | tail -1
[ 120.573945] softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
We can see this has a 60 second timeout by default.
If I then do
% echo > /dev/watchdog
% dmesg | tail -1
[ 154.514976] watchdog: watchdog0: watchdog did not stop!
We can see the watchdog hadn't timed out.
I then leave the machine idle for a minute and on the console I see
[ 214.624112] softdog: Initiating system reboot
and the OS reboots.
There are two types of watchdog; hardware and software. On the Orange Pi the SOC chip provides a hardware watchdog. If initialised then it needs to be pinged every so often, otherwise it performs a board reset.
However not many desktops have hardware watchdogs, so the kernel provides a software version. Now the kernel will try and keep track, and force a reboot. This isn't as good as a hardware watchdog because if the kernel, itself, breaks then nothing will trigger the reset. But it works.
The software watchdog can be initialised by loading the softdog
module
% modprobe softdog
% dmesg | tail -1
[ 120.573945] softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
We can see this has a 60 second timeout by default.
If I then do
% echo > /dev/watchdog
% dmesg | tail -1
[ 154.514976] watchdog: watchdog0: watchdog did not stop!
We can see the watchdog hadn't timed out.
I then leave the machine idle for a minute and on the console I see
[ 214.624112] softdog: Initiating system reboot
and the OS reboots.
answered 7 hours ago
Stephen Harris
25k24477
25k24477
Many desktops, laptops and servers include hardware watchdogs, often in their Super-I/O chips, or in their PCH; see the various “wdt” modules in the kernel.
– Stephen Kitt
7 hours ago
@StephenHarris Can I assume that when the commandecho > /dev/watchdog
doesn't work at first it's because there's no hardware watchdog for that device? Or there's still the possibility that I need to activate the hardware watchdog before using it?
– Rafael Muynarsk
7 hours ago
1
If/dev/watchdog
doesn't exist (or isn't a character device) and you know your hardware has a watchdog, then you may need tomodprobe
the relevant hardware driver... Modern distro's will try to load this automatically, but you may have an edge-case. None of my machines have a/dev/watchdog
entry :-(
– Stephen Harris
7 hours ago
1
“Many”, not “all” ;-). My last two personal PCs (2003, 2013) have supportediTCO_wdt
, and all my work PCs for the last decade or so have supported one driver or another, but it isn’t loaded automatically; as you mention, in many cases the relevant module needs to be loaded manually, and sometimes the firmware setup has to be configured appropriately too (and sometimes a jumper must be moved on the main board).
– Stephen Kitt
6 hours ago
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
6 hours ago
|
show 2 more comments
Many desktops, laptops and servers include hardware watchdogs, often in their Super-I/O chips, or in their PCH; see the various “wdt” modules in the kernel.
– Stephen Kitt
7 hours ago
@StephenHarris Can I assume that when the commandecho > /dev/watchdog
doesn't work at first it's because there's no hardware watchdog for that device? Or there's still the possibility that I need to activate the hardware watchdog before using it?
– Rafael Muynarsk
7 hours ago
1
If/dev/watchdog
doesn't exist (or isn't a character device) and you know your hardware has a watchdog, then you may need tomodprobe
the relevant hardware driver... Modern distro's will try to load this automatically, but you may have an edge-case. None of my machines have a/dev/watchdog
entry :-(
– Stephen Harris
7 hours ago
1
“Many”, not “all” ;-). My last two personal PCs (2003, 2013) have supportediTCO_wdt
, and all my work PCs for the last decade or so have supported one driver or another, but it isn’t loaded automatically; as you mention, in many cases the relevant module needs to be loaded manually, and sometimes the firmware setup has to be configured appropriately too (and sometimes a jumper must be moved on the main board).
– Stephen Kitt
6 hours ago
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
6 hours ago
Many desktops, laptops and servers include hardware watchdogs, often in their Super-I/O chips, or in their PCH; see the various “wdt” modules in the kernel.
– Stephen Kitt
7 hours ago
Many desktops, laptops and servers include hardware watchdogs, often in their Super-I/O chips, or in their PCH; see the various “wdt” modules in the kernel.
– Stephen Kitt
7 hours ago
@StephenHarris Can I assume that when the command
echo > /dev/watchdog
doesn't work at first it's because there's no hardware watchdog for that device? Or there's still the possibility that I need to activate the hardware watchdog before using it?– Rafael Muynarsk
7 hours ago
@StephenHarris Can I assume that when the command
echo > /dev/watchdog
doesn't work at first it's because there's no hardware watchdog for that device? Or there's still the possibility that I need to activate the hardware watchdog before using it?– Rafael Muynarsk
7 hours ago
1
1
If
/dev/watchdog
doesn't exist (or isn't a character device) and you know your hardware has a watchdog, then you may need to modprobe
the relevant hardware driver... Modern distro's will try to load this automatically, but you may have an edge-case. None of my machines have a /dev/watchdog
entry :-(– Stephen Harris
7 hours ago
If
/dev/watchdog
doesn't exist (or isn't a character device) and you know your hardware has a watchdog, then you may need to modprobe
the relevant hardware driver... Modern distro's will try to load this automatically, but you may have an edge-case. None of my machines have a /dev/watchdog
entry :-(– Stephen Harris
7 hours ago
1
1
“Many”, not “all” ;-). My last two personal PCs (2003, 2013) have supported
iTCO_wdt
, and all my work PCs for the last decade or so have supported one driver or another, but it isn’t loaded automatically; as you mention, in many cases the relevant module needs to be loaded manually, and sometimes the firmware setup has to be configured appropriately too (and sometimes a jumper must be moved on the main board).– Stephen Kitt
6 hours ago
“Many”, not “all” ;-). My last two personal PCs (2003, 2013) have supported
iTCO_wdt
, and all my work PCs for the last decade or so have supported one driver or another, but it isn’t loaded automatically; as you mention, in many cases the relevant module needs to be loaded manually, and sometimes the firmware setup has to be configured appropriately too (and sometimes a jumper must be moved on the main board).– Stephen Kitt
6 hours ago
1
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
6 hours ago
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
6 hours ago
|
show 2 more comments
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491814%2fis-it-possible-to-activate-the-watchdog-on-any-linux-machine%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown