标签:重启 linux func ash dex nta cti word repr
昨天做了一个udhcpd与udhcpc的守护,目前只会用shell模仿编写,还有什么方法可以做守护呢?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#! /bin/sh #进程名字可修改 PRO_NAME=udhcpc WLAN=ra0 while true ; do # 用ps获取$PRO_NAME进程数量 NUM=` ps aux | grep ${PRO_NAME} | grep - v grep | wc -l` # echo $NUM # 少于1,重启进程 if [ "${NUM}" -lt "1" ]; then echo "${PRO_NAME} was killed" ${PRO_NAME} -i ${WLAN} # 大于1,杀掉所有进程,重启 elif [ "${NUM}" -gt "1" ]; then echo "more than 1 ${PRO_NAME},killall ${PRO_NAME}" killall -9 $PRO_NAME ${PRO_NAME} -i ${WLAN} fi # kill僵尸进程 NUM_STAT=` ps aux | grep ${PRO_NAME} | grep T | grep - v grep | wc -l` if [ "${NUM_STAT}" -gt "0" ]; then killall -9 ${PRO_NAME} ${PRO_NAME} -i ${WLAN} fi done exit 0 |
标签:重启 linux func ash dex nta cti word repr
原文地址:https://www.cnblogs.com/lidabo/p/14004667.html