shell编写redis启动脚本
安装后redis,默认系统不会自启动,如果关机或重启redis不会自行启动,linux下/etc/init.d/目录下基本上存放所有系统的大多数的启动脚本,放在这个目录下的脚本可以实现自启动操作。
在 /etc/init.d/目录下创建redis的shell文件
#!/bin/bash
#config:/usr/local/src/redis.conf
#pidfile:/var/run/redis.pid
source /etc/init.d/functions
BIN="/usr/local/bin"
REDIS_CONFIG="/usr/local/src/redis.conf"
PIDFILE="/var/run/redis.pid"
###Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
RETVAL=
prog="redis-server"
desc="Redis Server" start(){ if [ -e $PIDFILE ];then
echo "$desc already running...."
exit
fi echo -n $"starting $desc:" daemon $BIN/$prog $REDIS_CONFIG & RETVAL=$? echo [ $RETVAL -eq ] && touch /var/lock/subsys/$prog
return $RETVAL } stop(){
echo -n $"Stop $desc" killproc $prog
RETVAL=$?
echo [ $RETVAL -eq ] && rm -f /var/lock/subsys/$prog $PIDFILE return $RETVAL } restart(){
stop
start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status $prog RETVAL=$? ;; *) echo $"Usage:$0{start|stop|restart|condrestart|status}" RETVAL= esac
exit $RETVAL
service redis start service redis stop service redis restart service redis status
都正常
将redis加入自启动计划
cd /etc/init.d/
chmod -R 775 redis
chkconfig --list|grep redis
添加启动计划到系统
[root@dongzi init.d]# chkconfig --add redis
service redis does not support chkconfi
再在脚本里面加入两行注释
# chkconfig: - 20 80
# description: Starts and stops the redis daemon.
运行正常
[root@dongzi init.d]# chkconfig --add redis
You have new mail in /var/spool/mail/root
[root@dongzi init.d]# chkconfig --list|grep redis
redis :off :off :off :off :off :off :off
You have new mail in /var/spool/mail/root
[root@dongzi init.d]# chkconfig --level redis on
[root@dongzi init.d]# chkconfig --list|grep redis
redis :off :off :on :on :on :on :off
shell编写redis启动脚本的更多相关文章
- Linux shell编写端口扫描脚本
Linux shell编写端口扫描脚本 需求: 扫描特定主机 扫描特定主机的特定端口 扫描特定网段 扫描特定网段中哪些主机开放了特定的端口 源码如下: #/bin/bash #该脚本用于对特定目标主机 ...
- centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课
centos LNMP第一部分环境搭建 LAMP安装先后顺序 LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/local/php/{ ...
- shell编写一个判断脚本
shell编写一个判断脚本 4.1问题 本例要求在虚拟机server0上创建/roo ...
- linux shell 之尝试编写 企业级 启动脚本
企业Shell面试题10:开发企业级MySQL启动脚本 说明: MySQL启动命令为: 1 /bin/sh mysqld_safe --pid-file=$mysqld_pid_file_path 2 ...
- 自己编写服务启动脚本(一):functions文件详细分析和说明
本文目录: 1.几个显示函数2.action函数3.is_true和is_false函数4.confirm函数5.pid检测相关函数 5.1 checkpid.__pids_var_run和__pid ...
- Ubuntu编写开机启动脚本
1 概述 服务器一般不可能百分之百不会挂,于是一般采用主备或者分布式来达到高可用. 挂掉的机器有很多处理策略,常用的就是重新启动,但是为了保证重启之后服务器能够恢复可用状态,需要配置开机启动脚本. 2 ...
- redis启动脚本
#!/bin/sh # # Simple Redis init.d script conceived to work on Linux systems # as it does use of the ...
- CentOS下的Redis启动脚本
这是一个Shell脚本,用于管理Redis进程(启动,停止,重启),如果你在使用Redis,这个脚本可供参考. #!/bin/sh # # redis - this script starts and ...
- 026_编写 nginx 启动脚本
#!/bin/bash#本脚本编写完成后,放置在/etc/init.d/目录下,就可以被 Linux 系统自动识别到该脚本#如果本脚本名为/etc/init.d/nginx,则 #service ng ...
随机推荐
- Python3.x:bs4解析html基础用法
Python3.x:bs4解析html基础用法 代码: import urllib.request from bs4 import BeautifulSoup import re url = r'ht ...
- 基于ORB的LinearBlend融合
// L14//基于ORB实现线性融合#include "stdafx.h"#include <vector>#include <opencv2/core.hpp ...
- node scripts/install.js 停顿解决办法
参考:node-sass 安装卡在 node scripts/install.js 解决办法 在安装hexo的时候,运行: npm install hexo-cli -g 卡死在了 node scri ...
- HTML 入门1
HTML 入门1 一,什么是HTML 超文本标记语言 二,如何写一个HTML文件? 1 通过sublime的文件->新建->保存 "文件名.html"格式 2,在 ...
- Vue学习笔记一:使用vue-cli 创建开发环境
第一步:安装Node.js 点击此处下载 选择对应的安装包,进行安装. 第二步:安装淘宝镜像 有一个问题,使用 npm 会导致网速很慢,对于大陆用户,建议将 npm 的注册表源设置为国内的镜像, ...
- LRIP UVALive - 7148 (点分治)
大意: 给定树, 每个点有点权, 求最长非减树链, 满足树链上最大值与最小值之差不超过D 点分治, 线段树维护最小值为$x$时的最长非增和非减树链即可. 实现时有技巧是翻转一下儿子区间, 这样可以只维 ...
- React中父子组件间的通信问题
1.https://blog.csdn.net/sinat_17775997/article/details/59103173 (React中父子组件间的通信问题)
- 在Jsp中调用静态资源,路径配置问题,jsp获取路径的一些方法
在Jsp中调用图片.JS脚本等,针对取得的路径有两种调用方式: 1.放入Body中生成绝对路径(不建议) <%@ page language="java" import=&q ...
- Scrum立会报告+燃尽图(3)选题
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2193 一.小组介绍 组长:刘莹莹 组员:朱珅莹 孙韦男 祝玮琦 王玉潘 ...
- oracle过滤某个字段重复记录,只获取一条记录
一,首先想到: 1,关键字distinct 2,group by 3,MAX,MIN这样的函数被称为聚集函数,和GROUP搭配起来用 但均无法实现,执行结果如下 举例: 表名:OffsiteOutre ...