分享Memcached shell启动停止脚本

 注意:要使用这个shell,必须先成功建立memcache环境
1》建立memcached文件和权限
[[email protected] ~]# touch /etc/init.d/memcached
[[email protected] ~]# chmod +x /etc/init.d/memcached
2》编写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: memcached

memcached_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 0

RETVAL=0
prog="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 1
esac
exit $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>
时间: 2024-08-04 14:12:56

分享Memcached shell启动停止脚本的相关文章

ubuntu下memcached启动停止脚本

工作需求,需要自己写一个memcached的启动停止脚本,呕心沥血,终于完成,虽然很搓很搓,还是记录一下吧,废话不多说直接上脚本 #! /bin/sh # ckconfig: - 55 45 # description: The memcached daemon is a network memory cache service. # processname: memcached # config: /etc/memcached.conf # Source function library -

Linux Oracle服务启动&amp;停止脚本与开机自启动

在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介绍一般而言如何启动oracle. 一.在Linux下启动Oracle 登录到CentOS,切换到oracle用户权限 # su – oracle 接着输入: $ sqlplus "/as sysdba" 原本的画面会变为SQL> 接着请输入SQL> startup 就可以正常的

Linux Oracle服务启动&停止脚本与开机自启动

Linux Oracle服务启动&停止脚本与开机自启动 http://www.cnblogs.com/mchina/archive/2012/11/27/2782993.html Linux Oracle服务启动&停止脚本与开机自启动

线上JAVA项目的目录结构分析,以及启动停止脚本

一般来说,JAVA项目最终上线都是以JAR或者WAR的形式发布 WAR的话就是WEB工程,JAR的话就是普通JAVA工程,可以直接启动,无需任何容器的 一般比较的固定的目录结构: 项目名称demo demo/bin这里一般是启动和停止脚本  start.sh  stop.sh demo/conf  系统配置文件 demo/base war工程的话,将war包放此 demo/*** demo/lib  war工程的话,不需要,因为war工程通过mvn构建,引用的jar包都会打在war包里,如果是j

Bash Shell启动配置脚本的顺序

1.Bash检查环境变量文件的方式,取决于系统运行Shell的方式,通常系统运行Shell有3种方式: 1)通过系统用户登陆后默认运行的Shell 2)非登陆交互式运行Shell 3)执行脚本运行非交互式Shell 2.第一种情况下,当用户登录Linux系统时,Shell会作为登陆Shell启动,此时Shell加载配置文件的顺序: 1)首先加载/etc/profile,这是linux系统默认的Shell主配置文件,每个登陆用户都会加载. 2)加载1后,才会执行/etc/profile.d目录下的

Ubuntu 启动停止脚本

/etc/init.d 目录下的开机启动脚本 1. more redis_8010 #/bin/sh #Configurations injected by install_server below.... EXEC=/usr/local/bin/redis-server CLIEXEC=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_8010.pid CONF="/etc/redis/8010.conf" REDISPORT="

Spring boot centos部署启动停止脚本

原文地址:http://www.cnblogs.com/skyblog/p/7243979.html 使用脚本启动和关闭服务,centos下的脚本启动和关闭可以如下: start(){ now=`date "+%Y%m%d%H%M%S"` exec java -Xms64m -Xmx256m -jar ./simple-service-0.0.1.jar --server.port=7085 --config.name=pro > logs/simple-service.log

linux bash启动停止脚本,第二弹

本文是之前的watchdate的shell脚本的改进wdate,同样先上图: 1)脚本加入chkconfig管理  head -5 /etc/init.d/wdate #!/bin/bash #auth:[email protected] # #wdate         Start/Stop the watchdate daemon # # chkconfig: 2345 71 55 chkconfig --add wdate 2)开始贴代码 #!/bin/bash #auth:[email 

使用 python 实现 memcached 的启动服务脚本 rc

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 8