分享一个php的启动关闭脚本(原)
自己简单写的一个php服务的启动脚本和大家分享
思路(实现的原理):
1:function模块+case语句多分支判断
2:通过添加# chkconfig: 2345 43 89注释实现开机自启动(前提是把脚本放入/etc/init.d/目录下 然后chmod给可执行权限,然后chkconfig --add phpd(脚本名称))
3:每次命令执行是否成功用$?是否为0来给予反馈
#!/bin/bash
# php-fpm Start/Stop php-fpm
#
# chkconfig:
#author andy
#date
#function php-fpm manager
#email fei1989118@.com
#version 1.0
#check service status
#usage
. /etc/init.d/functions
#define var
check=`netstat -lnutp|grep php-fpm|wc -l`
function usage(){ echo "usage:$0 {start|stop|restart|status}"
exit
}
function start(){ if [ "$1" = "start" -a $check -ne ];then
action "php is already started!" /bin/false
exit
elif [ "$1" = "start" -a $check -eq ];then
sleep
/usr/local/sbin/php-fpm
if [ $? = ];then
action "php start successfully!" /bin/true
else
action "php start failed!" /bin/false
exit
fi
fi
}
function stop(){
if [ "$1" = "stop" -a $check -eq ];then
action "php is not running!" /bin/false
exit
elif [ "$1" = "stop" -a $check -ne ];then
killall php-fpm
sleep
if [ $? = ];then
action "php stoped successfully!" /bin/true
else
action "php stoped failed!" /bin/false
exit
fi
fi
}
function restart(){
if [ "$1" = "restart" -a $check -eq ];then
action "php is not running!" /bin/false
sleep
/usr/local/sbin/php-fpm
if [ $? = ];then
action "php start successfully!" /bin/true
else
action "php start failed!" /bin/false
exit
fi elif [ "$1" = "restart" -a $check -ne ];then
killall php-fpm
if [ $? = ];then
action "php stoped successfully!" /bin/true
else
action "php stoped failed!" /bin/false
fi
sleep
/usr/local/sbin/php-fpm
if [ $? = ];then
action "php start successfully!" /bin/true
else
action "php start failed!" /bin/false
exit
fi
fi }
function status(){
if [ "$1" = "status" -a $check -eq ];then
echo "php is not running!"
exit
elif [ "$1" = "status" -a $check -ne ];then
echo "php is running"
exit
fi
} case "$1" in
start) start $
;;
stop) stop $
;;
restart) restart $
;;
status) status $
;;
*) usage $
esac
如果有不对的地方请多多指正
分享一个php的启动关闭脚本(原)的更多相关文章
- 分享一个mysql服务启动与关闭的bat文件
有时候打开数据库可视化工具(sqlyog.navicat)连接数据库时,会出现以下报错信息. 大家都知道是数据库的服务没有启动. 所以我想给大家分享一个bat文件可供快速启动mysql的数据库的服务, ...
- Ops:jar包启动关闭脚本
简介 公司开发架构为java语言的rpc dubbo架构,将功能分解为各个模块,模块较多,发布到环境上的应用为编译后的jar包和配置文件,以及启动关闭jar包的shell脚本.之前经常会出现进程启动不 ...
- VMware相关服务启动关闭脚本
VMware相关服务 VMware Authonrization Service:用于启动和访问虚拟机的授权和身份验证服务 VMware DHCP Service: IP自动分配协议——它不启动 虚拟 ...
- springboot启动关闭脚本
springboot项目jar包启动,application.properties.jar包.shell脚本.static目录(静态页面和jar包分离)在同一目录下 [start.sh] #!/bin ...
- 【4】Kafka集群启动/关闭脚本
说明:本脚本基于SSH服务器免密登录,如集群未配置SSH,参照:<SSH安装配置> . 一.启动脚本:start-kafka-cluster.sh #!/bin/bash brokers= ...
- Mongodb 启动关闭脚本并设置开机自动启动Mongodb
配置文件内容:[root@yoon etc]# cat mongod.conf logpath=/export/log/mongodb.loglogappend=truefork = truedbpa ...
- redis服务启动关闭脚本
代码如下: # chkconfig: 90 10 # description: service of redis for start and stop add by tomener PATH=/usr ...
- redis centos 6.x 启动关闭脚本
#!/bin/sh #Configurations injected by install_server below.... EXEC=/usr/local/bin/redis-server CLIE ...
- mysql启动关闭脚本
#!/bin/sh mysql_port= mysql_username="root" mysql_password="" function_start_mys ...
随机推荐
- Vue + Webpack + Vue-loader 系列教程(2)相关配置篇
原文地址:https://lvyongbo.gitbooks.io/vue-loader/content/ 使用预处理器 在 Webpack 中,所有的预处理器需要和一个相应的加载器一同使用.vue- ...
- webapi - 模型验证
本次要和大家分享的是webapi的模型验证,讲解的内容可能不单单是做验证,但都是围绕模型来说明的:首先来吐槽下,今天下午老板为自己买了套新办公家具,看起来挺好说明老板有钱,不好的是我们干技术的又成了搬 ...
- NLP点滴——文本相似度
[TOC] 前言 在自然语言处理过程中,经常会涉及到如何度量两个文本之间的相似性,我们都知道文本是一种高维的语义空间,如何对其进行抽象分解,从而能够站在数学角度去量化其相似性.而有了文本之间相似性的度 ...
- C++整数转字符串的一种方法
#include <sstream> //ostringstream, ostringstream::str() ostringstream stream; stream << ...
- HTTP API接口安全设计
HTTP API接口安全设计 API接口调用方式 HTTP + 请求签名机制 HTTP + 参数签名机制 HTTPS + 访问令牌机制 有没有更好的方案? OAuth授权机制 OAuth2.0服务 ...
- nexus 社区版3.0.2部署、访问
下载nexus社区办(oss): https://www.sonatype.com/download-oss-sonatype 目前最新版本 nexus-3.0.2-02-win64.zip nex ...
- Lesson 24 It could be worse
Text I entered the hotel manager's office and sat down. I had just lost £50 and I felt very upset. ' ...
- 【Java并发编程实战】-----“J.U.C”:CLH队列锁
在前面介绍的几篇博客中总是提到CLH队列,在AQS中CLH队列是维护一组线程的严格按照FIFO的队列.他能够确保无饥饿,严格的先来先服务的公平性.下图是CLH队列节点的示意图: 在CLH队列的节点QN ...
- [转]Android Binder设计与实现 - 设计篇
摘要 Binder是Android系统进程间通信(IPC)方式之一.Linux已经拥有管道,system V IPC,socket等IPC手段,却还要倚赖Binder来实现进程间通信,说明Binder ...
- ABP框架 - 模块系统
文档目录 本节内容: 简介 模块定义 生命周期方法 PreInitialize(预初始化) Initialize(初始化) PostInitialize(提交初始化) Shutdown(关闭) 模块依 ...