- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如何在看门狗执行之前执行一些脚本(在我的例子中,它将编写将日志复制到闪存或远程复制日志的脚本)?
我应该修改Linux内核看门狗驱动程序吗?如果是的话用什么方法?或者也许可以通过以下方式进行配置:
/etc/default/watchdog
/etc/watchdog.conf
但是我们安装了 busybox,但看门狗配置受到限制。我在谷歌上找不到任何东西,令人惊讶的是,这是需要解决的基本问题 - 每个人都希望在看门狗重置后在持久内存中拥有日志,闪存不是/var/log/路径的内容。
当然,在正常设备生命周期中不时将日志复制到闪存的解决方案并不是一个好主意,因为应该有一些解决方案,当喂食/dev/watchdog 的看门狗超时到期时如何执行此操作。
最佳答案
On a linux kernel newer than 4.9 you should have the availability of the pretimeout governor framework which would allow you to write a linux kernel driver which would react on the detection of a pre-timeout. A solution like this is well beyond the scope of a simple question and answer, so I'm leaving my original answer stand.
TL;博士:
If the problem is detectable while the OS is still running you can flush the logs. If the problem is caused by the OS locking up then you won't have an opportunity to fix the issue as hardware will reset the box.
这里有两件事:
看门狗设备通常是一个硬件计时器,当计时器到期时,它会执行“特别低级别的操作”。最常见的低级操作是重置盒子。如果发生在硬件中,则操作系统不参与其中。一旦计时器用完,你将没有机会做任何高级别的事情 - 例如在某处写入日志文件。
看门狗程序是一种工具,只要满足检查条件,它就会定期向看门狗设备保证安全。
busybox 看门狗定时器的条件是一个简单的循环(伪代码):
while (1) {
# reassure watchdog
# sleep some time
}
所以如果程序停止运行 - 例如通过操作系统锁定或程序终止,底层硬件将直接启动。
“更大”的看门狗二进制文件提供了一系列检查,如果它们失败,它将触发 /etc/watchdog.conf
中的 repair-binary
选项来尝试恢复。这将是刷新日志的潜在点。
关于c++ - 如何在看门狗执行之前将日志复制到闪存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55845216/
ATtiny88初体验(四):看门狗 ATtiny88单片机的看门狗使用内部独立的128KHz时钟源,拥有3种工作模式: Interrupt模式:超时产生中断; Syste
1、前言 假设现在有一个应用场景,需要对文件系统进行监控,发生变化时产生日志,对新增的文件做一些相应的操作。 比如说应用到我们之前的音乐高潮提取器:若当前文件夹下增加了一个音乐文件,监控器就调
我正在尝试编写一个程序,该程序可以检测是否已插入或拔出了耳机,并因此执行了某些操作。我使用的是Ubuntu 14.04,经过一番搜索,我发现耳机/耳机的连接状态已写入此路径下的编解码器文件-/ pro
我是 Python 的新手,我正在尝试实现良好的“文件创建”检测。如果我不放置 time.sleep(x),我的文件将以错误的方式详细说明,因为它们仍在文件夹中“创建”。 (缓冲区不为空)我如何在每次
Linux 上是否有用于以下目的的看门狗工具或库?我想构建一个看门狗可执行文件,它启动 2 个进程并在以下情况下重新启动它们: 进程崩溃 进程变得无响应(例如由于某种原因挂起) 互联网搜索找到了 wa
我正在尝试从 C 向 Raspbian 中的看门狗设备 - /dev/watchdog 提供数据。 问题是无论我如何尝试访问设备总是抛出忙碌或权限被拒绝的错误(因为进程已经在运行并由系统提供.....
嗨,我正在考虑使用 Python 在 Windows XP 上制作一个看门狗应用程序,它将执行以下操作: 在给定时间重新启动 Windows。 启动一个 exe 应用程序。 运行计时器以检查:应用程序
我打算使用 Python 看门狗来处理写入文件的目录,我只对图像文件感兴趣,麻烦的是我不太理解 this page 上的代码.这是我的尝试: from watchdog.observers impor
我正在使用 Watchdog监视网络目录,非递归的,随着时间的推移要创建的特定文件模式。我看到的问题是,虽然它在本地测试时效果很好,但如果我从远程计算机更改受监控的目录,则不会触发事件。 这里是我配置
Watchdog 非常棒,可以让您对特定目录进行递归快照。它甚至可以让您使用名为 DirectorySnapshotDiff 的函数比较快照. 我的程序会实时观察目录的变化,因此需要使用此函数的输出。
我在 threaded 进程环境中长时间运行 boost::regex_match(...) 调用时遇到问题。但它可能是另一个具有相同问题的库(API 调用)。 有没有通用的方法来设置看门狗? 对于非
我正在 Raspberry Pi 上开发一个系统,该系统使用 Web 界面与之交互,并具有自定义 C++ 服务器。这个想法是,您只需插入 Pi,不需要手动启动服务器。虽然这不是问题,但服务器有时会出现
我正在尝试实现一个看门狗,它将 ping 主机,如果它已启动,那么它将让 midori 打开远程页面,如果没有,那么它将打开本地页面。 我已根据此处的代码进行了改编:https://raspberry
我有一个无限期运行的实时数据采集器,每隔几秒通过 HTTP 采集数据并将其放入 MySQL 数据库中。 在我的程序中,我有一个 while True 循环,每当最后生成的时间大于 X 秒时,它就会生成
之前我是在Windows系统上开发OpenCl内核,现在我用的是Linux。在 Windows 上,有一个名为 watchdog 的巧妙功能,如果它持续超过 5 秒(默认情况下),它会自动停止 Ope
我正在使用 Watchdog 来监控目录并使其与 Dropbox 保持同步。 我遇到这样一种情况,每次我从 Dropbox 下载文件时,我都会触发一个上传事件,因为我需要写入 Watchdog 正在监
现在我遇到一个关于 Linux NMI Watchdog 的问题。我想使用 Linux NMI 看门狗来检测和恢复操作系统挂起。因此,我将“nmi_watchdog=1”添加到 grub.cfg 中。
我已经在 Ubuntu 10.04 上使用 Apache2 完成了 Phusion Passenger 设置。每当我重新启动 Apache 服务器时,我都会收到以下错误消息,并且 Rails 应用程序
我有一个运行 Debian 的 Beaglebone Black,我需要一个在后台运行的脚本,它会每隔几秒检查一次系统是否仍在运行。据我了解,BBB 中的看门狗是基于硬件的,独立于操作系统运行,因此即
我正在尝试使用 passenger 和 nginx 运行 rails。 Nginx 不会重定向到我的 Rails 应用程序,而是继续到其默认的 index.html 页面,我得到了这个错误: Unab
我是一名优秀的程序员,十分优秀!