将以下脚本保存为 /root/check_port_3800.sh
#!/bin/bash # 要检测的端口号 PORT=3800 # 检测端口是否启动 if ! netstat -tuln | grep -q ":$PORT"; then echo "$(date): Port $PORT is not running. Restarting the service..." >> /var/log/check_port_3800.log # 重启服务命令 nohup /root/gost/gost -L socks5://:3800 & >> /var/log/check_port_3800.log 2>&1 else echo "$(date): Port $PORT is running." >> /var/log/check_port_3800.log fi
给脚本文件设置权限
chmod +x /root/check_port_3800.sh
添加定时任务
* * * * * /bin/bash /root/check_port_3800.sh
发表回复
评论列表(0条)