判断一个进程是否live/存在,否则bash脚本重启。restart a process by shell script.
crontab -e # 设置每小时检查一次
0 * * * * * /var/scripts/restart.v2r.sh # 文件名不能包含v2ray or always false
mkdir -p /var/scripts/
vi /var/scripts/restart.v2r.sh
ps aux | grep v2ray | grep -v grep 或者 pgrep v2ray
#! /bin/bash
pid=$(pgrep v2ray)
if [ -z "$pid" ]
then
echo "v2ray is stopped..."
nohup /etc/v2ray &
else
echo "v2ray is running..."
fi
参考链接: