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 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 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 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 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 22 mins ago
Rafael Muynarsk
asked Dec 31 '18 at 20:09
Rafael MuynarskRafael Muynarsk
422615
422615
add a comment |
add a comment |
2 Answers
2
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
Dec 31 '18 at 20:39
@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
Dec 31 '18 at 20:45
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
Dec 31 '18 at 20:48
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
Dec 31 '18 at 21:33
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
Dec 31 '18 at 21:38
|
show 2 more comments
The I/O redirection closes the watchdog file handle after writing the 1
. Depending on how the watchdog device is configured, closing the file handle can also disable the watchdog.
Try
exec 3>/dev/watchdog
echo 1 >&3
This will keep the watchdog device open in the current shell, so the timer will not be stopped.
Most people run a dedicated watchdog daemon rather than using cron; this daemon runs a list of checks before resetting the timer, so the machine also reboots if tests fail. This could be used to verify that a database service actually processes queries, while regular service monitoring would only verify that the process is running.
add a comment |
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
2 Answers
2
active
oldest
votes
2 Answers
2
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
Dec 31 '18 at 20:39
@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
Dec 31 '18 at 20:45
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
Dec 31 '18 at 20:48
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
Dec 31 '18 at 21:33
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
Dec 31 '18 at 21:38
|
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
Dec 31 '18 at 20:39
@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
Dec 31 '18 at 20:45
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
Dec 31 '18 at 20:48
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
Dec 31 '18 at 21:33
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
Dec 31 '18 at 21:38
|
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 Dec 31 '18 at 20:30
Stephen HarrisStephen Harris
25.5k24477
25.5k24477
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
Dec 31 '18 at 20:39
@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
Dec 31 '18 at 20:45
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
Dec 31 '18 at 20:48
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
Dec 31 '18 at 21:33
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
Dec 31 '18 at 21:38
|
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
Dec 31 '18 at 20:39
@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
Dec 31 '18 at 20:45
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
Dec 31 '18 at 20:48
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
Dec 31 '18 at 21:33
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
Dec 31 '18 at 21:38
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
Dec 31 '18 at 20:39
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
Dec 31 '18 at 20:39
@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
Dec 31 '18 at 20:45
@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
Dec 31 '18 at 20:45
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
Dec 31 '18 at 20:48
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
Dec 31 '18 at 20:48
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
Dec 31 '18 at 21:33
“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
Dec 31 '18 at 21:33
1
1
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
Dec 31 '18 at 21:38
@Rafael the BIOS or UEFI setup on a PC.
– Stephen Kitt
Dec 31 '18 at 21:38
|
show 2 more comments
The I/O redirection closes the watchdog file handle after writing the 1
. Depending on how the watchdog device is configured, closing the file handle can also disable the watchdog.
Try
exec 3>/dev/watchdog
echo 1 >&3
This will keep the watchdog device open in the current shell, so the timer will not be stopped.
Most people run a dedicated watchdog daemon rather than using cron; this daemon runs a list of checks before resetting the timer, so the machine also reboots if tests fail. This could be used to verify that a database service actually processes queries, while regular service monitoring would only verify that the process is running.
add a comment |
The I/O redirection closes the watchdog file handle after writing the 1
. Depending on how the watchdog device is configured, closing the file handle can also disable the watchdog.
Try
exec 3>/dev/watchdog
echo 1 >&3
This will keep the watchdog device open in the current shell, so the timer will not be stopped.
Most people run a dedicated watchdog daemon rather than using cron; this daemon runs a list of checks before resetting the timer, so the machine also reboots if tests fail. This could be used to verify that a database service actually processes queries, while regular service monitoring would only verify that the process is running.
add a comment |
The I/O redirection closes the watchdog file handle after writing the 1
. Depending on how the watchdog device is configured, closing the file handle can also disable the watchdog.
Try
exec 3>/dev/watchdog
echo 1 >&3
This will keep the watchdog device open in the current shell, so the timer will not be stopped.
Most people run a dedicated watchdog daemon rather than using cron; this daemon runs a list of checks before resetting the timer, so the machine also reboots if tests fail. This could be used to verify that a database service actually processes queries, while regular service monitoring would only verify that the process is running.
The I/O redirection closes the watchdog file handle after writing the 1
. Depending on how the watchdog device is configured, closing the file handle can also disable the watchdog.
Try
exec 3>/dev/watchdog
echo 1 >&3
This will keep the watchdog device open in the current shell, so the timer will not be stopped.
Most people run a dedicated watchdog daemon rather than using cron; this daemon runs a list of checks before resetting the timer, so the machine also reboots if tests fail. This could be used to verify that a database service actually processes queries, while regular service monitoring would only verify that the process is running.
answered Jan 1 at 5:02
Simon RichterSimon Richter
2,4991113
2,4991113
add a comment |
add a comment |
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.
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