redis启动、关闭脚本
#!/bin/bash
PORT=
NAME=redis-server
ID=`ps -ef | grep "$NAME" | grep -v "grep" | awk '{print $2}'`
#CHECK_PORT=`netstat -tnlp|grep "\b$PORT\b"`
REDIS_SERVER=/usr/local/redis/bin/redis-server
REDIS_CONFIG=/usr/local/redis/etc/redis.conf
RETAVL=
#检查shelk公共函数库是否存在,存在就加载
FUNCTIONS_PATH=/etc/init.d/functions
[ -f $FUNCTIONS_PATH ]&& source $FUNCTIONS_PATH
#检查redis文件是否存在并可执行
[ -x $REDIS_SERVER ]|| exit #定义函数
#检查是否执行成功
check(){
RETAVL=$?
if
[ $RETAVL -eq ];then
action "redis is $1" /bin/true
else
action "redis is $1" /bin/false
fi
}
#启动服务
start(){
$REDIS_SERVER $REDIS_CONFIG
RETVAL=$?
if [ $RETVAL -eq ]; then
echo "redis is started!";
else
echo "redis start failed!";
fi
return $RETAVL }
#停止服务
stop(){
for id in $ID
do
kill - $id
done
RETVAL=$?
if [ $RETVAL -eq ]; then
echo "redis is stopped!";
else
echo "redis stop failed!";
fi
return $RETVAL;
} #redis启动状态
status(){
STATUS=$(pgrep redis-server | wc -l)
if [[ $STATUS -eq ]];then
echo "redis is not running!";
else
echo "redis is running!";
fi
} #重启服务
restart(){
stop
sleep
start
} #判断
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $"Usage:$0{start|stop|restart|help}"
esac
exit $RETAVL
redis启动、关闭脚本的更多相关文章
- redis 启动停止脚本
redis 启动停止脚本,该redis需要密码登录,如没有密码,去掉stop函数里的 -a #!/bin/sh # #chkconfig: 2345 80 90 # Simple Redis init ...
- Ops:jar包启动关闭脚本
简介 公司开发架构为java语言的rpc dubbo架构,将功能分解为各个模块,模块较多,发布到环境上的应用为编译后的jar包和配置文件,以及启动关闭jar包的shell脚本.之前经常会出现进程启动不 ...
- Linux下一个Redis启动/关闭/重新启动服务脚本
脚本功能: 实现redis单机多实例情况下的正常启动.关闭.重新启动单个redis实例.完毕系统标准服务的下面经常使用功能: start|stop|status|restart 注:redis程序代 ...
- 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 ...
- VMware相关服务启动关闭脚本
VMware相关服务 VMware Authonrization Service:用于启动和访问虚拟机的授权和身份验证服务 VMware DHCP Service: IP自动分配协议——它不启动 虚拟 ...
- 分享一个php的启动关闭脚本(原)
自己简单写的一个php服务的启动脚本和大家分享 思路(实现的原理): 1:function模块+case语句多分支判断 2:通过添加# chkconfig: 2345 43 89注释实现开机自启动(前 ...
- 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 ...
随机推荐
- Windows如何打开/关闭 服务
先右键Windows主菜单,点击计算机管理: 点击服务和应用程序: 点击服务:
- layui 后台分页
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- .symtab
参考:剖析.o文件ELF组成 目标文件 .symtab中记录的符号是从.s文件来的,所以.s这个汇编文件很关键. .symtab所记录符号的种类 示例代码 a.c ; static float a_v ...
- javascript方法注释
参考资源 文章标题:Javascript注释规范 文章地址:https://blog.csdn.net/lianlin21212411/article/details/78530913 /** * @ ...
- CentOS阿里仓库停止openstack mitaka源服务报错------“No package centos-release-openstack-mitaka available.”
之前学习了一个月的openstack的mitaka版本,部署完后放置一段时间,最近准备正式部署突然发现“No package centos-release-openstack-mitaka avail ...
- 【Java】用五种语言写数组(用于自己学习)
C语言 #include<stdio.h> int main() { ] = {, , , , , , , , , }; int i; ;i<;i++) printf("% ...
- Selenium常用API的使用java语言之12-定位一组元素
在第(五)节我们已经学习了8种定位方法, 那8种定位方法是针对单个元素定位的, WebDriver还提供了另外8种用于定位一组元素的方法. import org.openqa.selenium.By; ...
- c语言数组越界的避免方法
1.尽量显式地指定数组的边界 #define MAX 10 - int a[MAX]={1,2,3,4,5,6,7,8,9,10}; 在 C99 标准中,还允许我们使用单个指示符为数组的两段" ...
- [ Educational Codeforces Round 65 (Rated for Div. 2)][二分]
https://codeforc.es/contest/1167/problem/E E. Range Deleting time limit per test 2 seconds memory li ...
- HDU-5446-UnknownTreasure(组合数,中国剩余定理)
链接: http://acm.hdu.edu.cn/showproblem.php?pid=5446 题意: On the way to the next secret treasure hiding ...