脚本内容如下;

#!/bin/bash## redis - this script starts and stops the redis-server daemon## chkconfig:   - 80 12# description:  Redis is a persistent key-value database# processname: redis-server# config:      /etc/redis/redis.conf# pidfile:     /var/run/redis.pid   source/etc/init.d/functions   BIN="/usr/local/bin"CONFIG="/etc/redis/redis.conf"PIDFILE="/var/run/redis.pid"     ### Read configuration[-r"$SYSCONFIG"]&&source"$SYSCONFIG"   RETVAL=0prog="redis-server"desc="Redis Server"   start(){           if[-e$PIDFILE];thenecho"$desc already running...."exit1fi           echo-n $"Starting $desc: "         daemon $BIN/$prog$CONFIG           RETVAL=$?echo[$RETVAL-eq0]&&touch/var/lock/subsys/$progreturn$RETVAL}   stop(){echo-n $"Stop $desc: "         killproc $progRETVAL=$?echo[$RETVAL-eq0]&&rm-f/var/lock/subsys/$prog$PIDFILEreturn$RETVAL}   restart(){     stop     start }   case"$1"in   start)         start         ;;   stop)         stop         ;;   restart)         restart         ;;   condrestart)[-e/var/lock/subsys/$prog]&& restart         RETVAL=$?;;   status)         status $progRETVAL=$?;;*)echo $"Usage: $0 {start|stop|restart|condrestart|status}"RETVAL=1esac   exit$RETVAL

下载脚本:艺搜下载

将下载下来的脚本放在/etc/init.d/目录下

  • 更改脚本权限
chmod 777 /etc/init.d/redis 
  • 测试
service redis start 

参见编写Nginx启停服务脚本

编写Redis启停服务脚本的更多相关文章

  1. 编写Nginx启停服务脚本

    在/etc/init.d/目录下创建脚本 vim /etc/init.d/nginx 编写脚本内容:(其中下面2行需要根据情况自行修改) nginxd=/opt/nginx/sbin/nginx ng ...

  2. shell启停服务脚本模板

    一. 启动脚本模板:符合幂等性 如果该服务已经启动,再次调用该脚本,不会报错,也就是说可以反复多次调用,另外启动成功返回 一个参数,提供给自动发布平台校验该服务是否启动 #!/bin/bash ins ...

  3. Redis windows版本的启停bat脚本命令

    Reids windows版本安装 redis windows官网推荐:https://github.com/MicrosoftArchive/redis/releases 下载解压即可. 启停bat ...

  4. redis开机自动服务脚本

    1.设置redis.conf中daemonize为yes,确保守护进程开启. 2.编写开机自启动脚本 基本原理为: 系统开机启动时会去加载/etc/init.d/下面的脚本,通常而言每个脚本文件会自定 ...

  5. nginx启停shell脚本

    #!/bin/bash # 编写 nginx 启动脚本 # 本脚本编写完成后,放置在/etc/init.d/目录下,就可以被 Linux 系统自动识别到该脚本 # 如果本脚本名为/etc/init.d ...

  6. redis启停

    1 查看服务器上启动的redis服务 开了两个redis单机服务,监听在两个端口. 开了一个集群,监听在6个端口. [root@localhost bin]# ps aux | grep redis ...

  7. 编写使用systemctl启动服务脚本

    CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,还是存在系统服务里吧,即:/usr ...

  8. MySQL - 启停服务

    Windows 环境 命令行方式 启动 MySQL 服务: net start mysql停止 MySQL 服务: net stop mysql 注:需要以管理员身份启动 cmd 后再执行上述命令. ...

  9. 04. 启停redis服务

    启动 查看redis.conf文件,可以通过general中的说明,配置通过systemd来启停redis和查看redis状态(作者没有采用,而是使用service管理,service配置参考< ...

随机推荐

  1. ecshop修改后台访问地址

    本文转自‘做个好男人’的博客. 打开data/config.php,找到define(’ADMIN_PATH’,’admin’),这里是定义后台目录的地方,把其中的admin换成你的后台自定义目录,如 ...

  2. 【leetcode】Best Time to Buy and Sell 2(too easy)

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  3. 【leetcode】Valid Sudoku (easy)

    题目:就是判断已有的数字是否冲突无效,若无效返回flase 有效返回true 不要求sudo可解 用了char型的数字,并且空格用‘.'来表示的. 思路:只要分别判断横向 竖向 3*3小块中的数字是否 ...

  4. 【2016-08-18】转载:总结C++中几种结构体初始化的方法

    作者:Ac_Von 博客地址:http://www.cnblogs.com/vongang/ 文章地址:http://www.cnblogs.com/vongang/archive/2011/07/3 ...

  5. 建立controller

    复制controller,重建controller 改: @Controller("[productController]") @RequestMapping("/[pr ...

  6. 10.11 cocoapods安装

    手动安装gem 手动下载 rubygem https://rubygems.org/pages/download#formats 10.11 cocoapods安装 sudo gem install ...

  7. 查看当前文件系统 df -lhT -B G

    [root@ok-T test]# df -lhT -B G Filesystem Type 1G-blocks Used Available Use% Mounted on /dev/mapper/ ...

  8. C#回顾 - 3.NET的IO:字节流

    使用 Stream 类管理字节流 使用 FileStream 类管理文件数据 使用 MemoryStream 类管理内存数据 使用 BufferedSream 类提高流性能   3.1 FileStr ...

  9. Ubuntu中给eclipse和android studio添加桌面快捷图标

    Ubuntu 12.04 创建应用程序启动项(可在Unity LaucherPad显示) http://www.cnblogs.com/bluestorm/archive/2012/10/12/272 ...

  10. Delphi函数参数传递 默认参数(传值)、var(穿址)、out(输出)、const(常数)四类

    Delphi的参数可以分为:默认参数(传值).var(传址).out(输出).const(常数)四类 可以对比C/C++的相关知识,类比学习. 1.默认参数是传值,不会被改变,例子 function ...