当前位置:Gxlcms > 数据库问题 > Redis数据库启动脚本

Redis数据库启动脚本

时间:2021-07-01 10:21:17 帮助过:23人阅读

  1. #!/bin/sh
  2. #author:taokey
  3. #date:2016-05-06
  4. #chkconfig:    345 85 15
  5. #description:   Redis is a persistent key-value database
  6. #processname:   redis-server
  7. #config:        /etc/redis/6379.conf
  8. #config:        /var/redis
  9. #pidfile:       /var/redis/run/redis_6379.pid
  10. #Source networking configuration.
  11. . /etc/sysconfig/network
  12. #check that networking is up.
  13. [ "$NETWORKING" = "no" ] && exit 0
  14. redis="/usr/local/bin/redis-server"
  15. CLI="/usr/local/bin/redis-cli"
  16. prog=$(basename $redis)
  17. arog=$(basename $CLI)
  18. REDIS_CONF_FILE="/etc/redis/6379.conf"
  19. pidfile="/var/redis/run/redis_6379.pid"
  20. [ -f /var/redis ] && . /var/redis
  21. lockfile=/var/lock/subsys/redis
  22. start() {
  23.         [ -x $redis ] || exit 5  
  24.         [ -f $REDIS_CONF_FILE ] || exit 6
  25.         echo $"Starting $prog:"
  26.         $redis $REDIS_CONF_FILE
  27.                 retval=$?
  28.                 echo 
  29.                 [ $retval -eq 0 ] && touch $lockfile
  30.                 return $retval
  31. }
  32. stop (){
  33.         echo "Stopping $prog: "
  34.         $CLI shutdown
  35.                 retval=$?
  36.                 if [ -f $pidfile ]
  37.                 then
  38.                         kill $pidfile
  39.                         retval=$?
  40.                 else
  41.                         echo "$prog shutdown" >/dev/null 2>&1
  42.                 fi
  43.                 echo 
  44.                 [ $retval -eq 0 ] && rm -f $lockfile
  45.                 return $retval
  46. }
  47. restart(){
  48.         stop
  49.         start
  50.         }
  51. case "$1" in
  52.         start)
  53.         start
  54.         ;;
  55.         stop)
  56.         stop
  57.         ;;
  58.         restart)
  59.         restart
  60.         ;;
  61. *)
  62.         echo $"Usage: $0 {start|stop|restart}"
  63.         exit 2
  64. esac

本文出自 “岁月在流逝,光辉依然在” 博客,请务必保留此出处http://taokey.blog.51cto.com/4633273/1770848

Redis数据库启动脚本

标签:networking   数据库   database   local   

人气教程排行