1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#!/bin/bash # 检查Nginx是否运行 if pgrep nginx > /dev/null 2>&1; then echo "Nginx is running." exit 0 else echo "Nginx is not running. Starting Nginx..." systemctl start nginx # 检查Nginx是否启动成功 if pgrep nginx > /dev/null 2>&1; then echo "Nginx started successfully." exit 0 else echo "Failed to start Nginx." exit 1 fi fi |