Created
March 4, 2018 17:03
-
-
Save watsy0007/a98e76d2f0a7e681e5efbc1a66fa76cf to your computer and use it in GitHub Desktop.
monitor shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
host_dir=`echo ~` # 当前用户根目录 | |
proc_name="net_speeder" # 进程名 | |
file_name="/root/log/netspeed.log" # 日志文件 | |
pid=0 | |
proc_num() # 计算进程数 | |
{ | |
num=`ps -ef | grep $proc_name | grep -v grep | wc -l` | |
return $num | |
} | |
proc_id() # 进程号 | |
{ | |
pid=`ps -ef | grep $proc_name | grep -v grep | awk '{print $2}'` | |
} | |
proc_num | |
number=$? | |
if [ $number -eq 0 ] # 判断进程是否存在 | |
then | |
~/net-speeder-master/net_speeder venet0 "tcp src port 443" >/dev/null 2>&1 & # 重启进程的命令 | |
proc_id # 获取新进程号 | |
echo ${pid}, `date` >> $host_dir$file_name # 将新进程号和重启时间记录 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment