Linux下看门狗的脚本实现

  看门狗watchdog程序:

helloworld.exe是一个可执行程序,源程序是:helloworld.c为

#include<stdio.h>
int main()
{
   printf("helloworld");
   return 0;
}

 守护进程为,脚本相似的看看门狗:

#!/bin/sh
hello=`ps -ef| grep helloworld.exe|grep -v grep |awk '{print $2}'`
while true;
do
if [ ! $hello ]; then
./helloworld.exe
fi
done

 其他的资料的可参考:

https://github.com/chxuan/cpp-utils

猜你喜欢

转载自blog.csdn.net/weixin_39752599/article/details/109252224