分享Memcached shell啟動停止指令碼

來源:互聯網
上載者:User

標籤:shell   memcached   linux   

 注意:要使用這個shell,必須先成功建立memcache環境1》建立memcached檔案和許可權[[email protected] ~]# touch /etc/init.d/memcached[[email protected] ~]# chmod +x /etc/init.d/memcached2》編寫Memcached shell管理指令碼  vi  /etc/init.d/memcached#!/bin/bash# memcached  - This shell script takes care of starting and stopping memcached.## chkconfig: - 90 10# description: Memcache provides fast memory based storage.# processname: memcachedmemcached_path="/usr/local/bin/memcached"memcached_pid="/var/run/memcached.pid"memcached_memory="1024"# Source function library.. /etc/rc.d/init.d/functions[ -x $memcached_path ] || exit 0RETVAL=0prog="memcached"# Start daemons.start() {    if [ -e $memcached_pid -a ! -z $memcached_pid ];then        echo $prog" already running...."        exit 1    fi    echo -n $"Starting $prog "    # Single instance for all caches    $memcached_path -m $memcached_memory -l 0.0.0.0 -p 11211 -u root -d -P $memcached_pid    RETVAL=$?    [ $RETVAL -eq 0 ] && {        touch /var/lock/subsys/$prog        success $"$prog"    }    echo    return $RETVAL}# Stop daemons.stop() {    echo -n $"Stopping $prog "    killproc -d 10 $memcached_path    echo    [ $RETVAL = 0 ] && rm -f $memcached_pid /var/lock/subsys/$prog    RETVAL=$?    return $RETVAL}# See how we were called.case "$1" in        start)            start            ;;        stop)            stop            ;;        status)            status $prog            RETVAL=$?            ;;        restart)            stop            start            ;;        *)            echo $"Usage: $0 {start|stop|status|restart}"            exit 1esacexit $RETVAL##############本指令碼中的下面二個配置可根據實際而配置#############memcached_path="/usr/local/bin/memcached" #memcached_memory="1024"3》 追究該指令碼為系統服務chkconfig --add memcached  chkconfig memcached on

4》測試(試試手啊)
<p>service memcached start|stop|status|restart </p>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.