memcached的启动脚本

发布时间:2020-02-16编辑:脚本学堂
memcached的启动脚本,没错,就是memcahced的启动脚本。/etc/init.d/memcached中加入以下内容,并设置号权限。

memcached的启动脚本,没错,就是memcahced的启动脚本。
在/etc/init.d/memcached中加入以下内容,并设置号权限。
 

复制代码 代码如下:
#!/bin/bash
#
# Save me to /etc/init.d/memcached
# And add me to system start
# chmod +x memcached
# chkconfig --add memcached
# chkconfig --level 35 memcached on
#
# Written by lei
#
# chkconfig: - 80 12
# description: Distributed memory caching daemon
#
# processname: memcached
# config: /usr/local/memcached/my.conf
 
source /etc/rc.d/init.d/functions
 
### Default variables
PORT="11211"
USER="root"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
SYSCONFIG="/usr/local/memcached/my.conf"
 
### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
 
RETVAL=0
prog="/usr/local/memcached/bin/memcached"
desc="Distributed memory caching"
 
start() {
    echo -n $"Starting $desc ($prog): "
    daemon $prog -d -p $PORT -u $USER -c $MAXCONN -m $CACHESIZE $OPTIONS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
    return $RETVAL
}
 
stop() {
    echo -n $"Shutting down $desc ($prog): "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/memcached
    return $RETVAL
}
 
restart() {
    stop
    start
}
 
reload() {
    echo -n $"Reloading $desc ($prog): "
    killproc $prog -HUP
    RETVAL=$?
    echo
    return $RETVAL
}
 
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  condrestart)
    [ -e /var/lock/subsys/$prog ] && restart
    RETVAL=$?
    ;;
  reload)
    reload
    ;;
  status)
    status $prog
    RETVAL=$?
    ;;
   *)
    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
    RETVAL=1
esac
 
exit $RETVAL