Shell 脚本:判断并启动 Nginx 服务
#!/bin/bash
检查nginx进程是否存在
nginx_process=$(ps -ef | grep nginx | grep -v grep)
if [ -z '$nginx_process' ]; then echo 'Nginx is not running. Starting nginx...' # 启动nginx服务 sudo service nginx start else echo 'Nginx is already running.' fi
原文地址: https://www.cveoy.top/t/topic/pe7W 著作权归作者所有。请勿转载和采集!