shell脚本
1,nginx服务管理脚本
使用源码包安装Nginx不含带服务管理脚本,也就是不能使用"service nginx start"或"/etc/init.d/nginxstart",所以写了以下的服务管理脚本。
#!/bin/bash program=/apps/nginx/sbin/nginx pid=/apps/nginx/logs/nginx.pid function start { if [ -f $pid ];then echo "nginx 服务已经处于开启状态" else $program fi } function stop { if [ ! $pid ];then echo "nginx 服务已经关闭" else $program -s stop echo "关闭服务 ok" fi } function status { if [ -f $pid ];then echo "服务正在运行..." else echo "服务已经关闭" fi } case $1 in start) start;; stop) stop;; restart) stop sleep 1 start;; status) status;; *) echo "你输入的语法格式错误" esac