sudo gedit /etc/xrdp/startwm.sh 在. /etc/X11/Xsession 前一行插入 xfce4-session
sudo service xrdp restart
name=Reconnect
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=5910
# modinfo softdog
filename: /lib/modules/3.2.0-4-686-pae/kernel/drivers/watchdog/softdog.ko
2. 加载模块
# insmod /lib/modules/3.2.0-4-686-pae/kernel/drivers/watchdog/softdog.ko
3. 此刻可见/dev/watchdog, 或创建
# mknod /dev/watchdog c 10 130
4. 查看dev并赋予权限
# ls -l /dev/watchdog
crw------- 1 root root 10, 130 Mar 21 16:27 /dev/watchdog# chmod o+rw /dev/watchdog
5. 测试使用watch dog
简单可写为:
# echo 0 > /dev/watchdog ///从此刻起计时,启用watchdog
# echo -n V > /dev/watchdog ///停用watchdog
6. 硬件与软件watchdog的区别
硬件watchdog必须有硬件电路支持, 设备节点/dev/watchdog对应着真实的物理设备, 不同类型的硬件watchdog设备由相应的硬件驱动管理。软件watchdog由一内核模块softdog.ko 通过定时器机制实现,/dev/watchdog并不对应着真实的物理设备,只是为应用提供了一个与操作硬件watchdog相同的接口。
硬件watchdog比软件watchdog有更好的可靠性。 软件watchdog基于内核的定时器实现,当内核或中断出现异常时,软件watchdog将会失效。而硬件watchdog由自身的硬件电路控制, 独立于内核。无论当前系统状态如何,硬件watchdog在设定的时间间隔内没有被执行写操作,仍会重新启动系统
看门狗是混杂设备,所以主设备号是10,/include/linux/miscdevice.h 中定义他的次设备号为130
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h> #include <errno.h> #include <signal.h> #include <time.h> #include <pthread.h> #include <sys/time.h> #include <linux/watchdog.h> #include <sys/ioctl.h> time_t backTime; struct tm *pBackTime; int wt_fd; static void sigAlarm(int sig) { '; (void)time(&backTime); pBackTime= localtime(&backTime); printf("day: %d; hour: %d; min: %d; sec: %d\n", pBackTime->tm_mday, pBackTime->tm_hour, pBackTime->tm_min, pBackTime->tm_sec); write(wt_fd, &flag, ); //Reset Watchdog 喂狗 alarm(); return; } int main() { char flag = 'V'; int ret; ; if(SIG_ERR == signal(SIGALRM, sigAlarm)) { perror("signal (SIGALARM) error"); } wt_fd = open("/dev/watchdog", O_RDWR); ) { printf("Fail to open watchdog device!\n"); } else { write(wt_fd,NULL,); printf("Turn on Watch Dog\n"); ret = ioctl(wt_fd, WDIOC_SETTIMEOUT, &timeout); if(EINVAL == ret) { printf("EINVAL Returned\n"); } else if(EFAULT == ret) { printf("EFAULT Returned\n"); } == ret) { printf("Set timeout %d secs success\n", timeout); } else { printf("Ret %d\n", ret); } } alarm(); ); write(wt_fd, &flag, ); printf("Turned off Watch Dog\n"); close(wt_fd); ; }
http://blog.sina.com.cn/s/blog_69a04cf401016gz4.html