這篇文章主要介紹redis啟動管理腳本怎么寫,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)公司,專注為中小企業(yè)提供官網(wǎng)建設(shè)、營銷型網(wǎng)站制作、自適應(yīng)網(wǎng)站建設(shè)、展示型做網(wǎng)站、成都做網(wǎng)站等服務(wù),幫助中小企業(yè)通過網(wǎng)站體現(xiàn)價值、有效益。幫助企業(yè)快速建站、解決網(wǎng)站建設(shè)與網(wǎng)站營銷推廣問題。
我是源碼安裝的redis-3.0.5
安裝路徑/usr/local/redis
編輯創(chuàng)建腳本文件:
vim /etc/init.d/redis
#!/bin/sh # # chkconfig: 2345 85 15 # description: this script can manager the redis-server daemon # Redis is a persistent key-value database # exec: /usr/local/redis/bin/redis-server # config: /usr/local/redis/conf/redis.conf # pidfile: /usr/local/redis/logs/redis.pid # datafile: /usr/local/redis/data/redis.rdb redis="/usr/local/redis/bin/redis-server" REDIS_CONF_FILE="/usr/local/redis/conf/redis.conf" prog=$(basename $redis) lockfile=/var/lock/subsys/redis # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 start() { [ -x $redis ] || exit 5 [ -f $REDIS_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $redis $REDIS_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { stop start } reload() { echo -n $"Reloading $prog: " killproc $redis -HUP RETVAL=$? echo } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart) $1 ;; reload) rh_status_q || exit 7 $1 ;; status) rh_status ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}" exit 2 esac
修改腳本操作權(quán)限,添加可執(zhí)行權(quán)限
chmod 755 /etc/init.d/redis
以上是“redis啟動管理腳本怎么寫”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!