<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[MacBook下的watch安装方法brew install watch， Linux 自带的 watchdog 的简介,Linux 软件看门狗 watchdog。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Thu, 09 Oct 2014 12:58:07 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	MacBook下的watch安装方法brew install watch：<br/>brew install watch (mac os)<br/><a href="https://www.jianshu.com/p/d75e50e38bb9" target="_blank">https://www.jianshu.com/p/d75e50e38bb9</a><br/><br/>背景：<br/>root@119.10.6.23:/usr/local/php# ps aux&#124;grep watchdog<br/>root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;0.0&nbsp;&nbsp;0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S&nbsp;&nbsp;&nbsp;&nbsp;Aug28&nbsp;&nbsp; 4:50 [watchdog/0]<br/>root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;0.0&nbsp;&nbsp;0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S&nbsp;&nbsp;&nbsp;&nbsp;Aug28&nbsp;&nbsp; 4:11 [watchdog/1]<br/>root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;14&nbsp;&nbsp;0.0&nbsp;&nbsp;0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S&nbsp;&nbsp;&nbsp;&nbsp;Aug28&nbsp;&nbsp; 3:58 [watchdog/2]<br/>root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;18&nbsp;&nbsp;0.0&nbsp;&nbsp;0.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp; 0 ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S&nbsp;&nbsp;&nbsp;&nbsp;Aug28&nbsp;&nbsp; 3:36 [watchdog/3]<br/>附:<br/>最简单的安装教程(CentOS)<br/>yum install watchdog -y<br/>modprobe softdog<br/>chkconfig watchdog&nbsp;&nbsp;on<br/>/etc/init.d/watchdog start<br/><br/>配置看门狗程序，开机自动运行<br/>chkconfig watchdog on<br/>启动看门狗<br/>sudo /etc/init.d/watchdog start<br/>——————————————————————————————————————<br/>&nbsp;&nbsp;&nbsp;&nbsp; Linux 自带了一个 watchdog 的实现，用于监视系统的运行，包括一个内核 watchdog module 和一个用户空间的 watchdog 程序。内核 watchdog 模块通过 /dev/watchdog 这个字符设备与用户空间通信。用户空间程序一旦打开 /dev/watchdog 设备（俗称“开门放狗”），就会导致在内核中启动一个1分钟的定时器（系统默认时间），此后，用户空间程序需要保证在1分钟之内向这个设备写入数据（俗称“定期喂狗”），每次写操作会导致重新设定定时器。如果用户空间程序在1分钟之内没有写操作，定时器到期会导致一次系统 reboot 操作（“狗咬人了”呵呵）。通过这种机制，我们可以保证系统核心进程大部分时间都处于运行状态，即使特定情形下进程崩溃，因无法正常定时“喂狗”，Linux系统在看门狗作用下重新启动（reboot），核心进程又运行起来了。多用于嵌入式系统。<br/><br/><br/>打开 /dev/watchdog 设备（“开门放狗”）：<br/><br/><textarea name="code" class="php" rows="15" cols="100">
int fd_watchdog = open(&quot;/dev/watchdog&quot;, O_WRONLY);&nbsp;&nbsp;
if(fd_watchdog == -1) &#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;int err = errno;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;&#92;n!!! FAILED to open /dev/watchdog, errno: %d, %s&#92;n&quot;, err, strerror(err));&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;syslog(LOG_WARNING, &quot;FAILED to open /dev/watchdog, errno: %d, %s&quot;, err, strerror(err));&nbsp;&nbsp;
&#125;&nbsp;&nbsp;
</textarea><br/>每隔一段时间向 /dev/watchdog 设备写入数据（“定期喂狗”）：<br/><textarea name="code" class="php" rows="15" cols="100">
//feed the watchdog&nbsp;&nbsp;
if(fd_watchdog &gt;= 0) &#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;static unsigned char food = 0;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;ssize_t eaten = write(fd_watchdog, &amp;food, 1);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;if(eaten != 1) &#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts(&quot;&#92;n!!! FAILED feeding watchdog&quot;);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;syslog(LOG_WARNING, &quot;FAILED feeding watchdog&quot;);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;
&#125;&nbsp;&nbsp;
</textarea><br/><br/>关闭 /dev/watchdog 设备，通常不需要这个步骤：<br/><textarea name="code" class="php" rows="15" cols="100">
close(fd_watchdog);&nbsp;&nbsp;
</textarea><br/><br/>所需头文件：<br/><br/><textarea name="code" class="php" rows="15" cols="100">
#include &lt;unistd.h&gt;&nbsp;&nbsp;
#include &lt;sys/stat.h&gt;&nbsp;&nbsp;
#include &lt;syslog.h&gt;&nbsp;&nbsp;
#include &lt;errno.h&gt;&nbsp;&nbsp;
</textarea><br/><br/>转自:http://blog.csdn.net/liigo/article/details/9227205<br/>摘自：http://bbs.linuxtone.org/thread-19567-1-1.html<br/>摘自：http://wjjchen.blog.163.com/blog/static/1628722201342354415584/
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] MacBook下的watch安装方法brew install watch， Linux 自带的 watchdog 的简介,Linux 软件看门狗 watchdog。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>