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

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

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

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  2. Linux Oracle服务启动&停止脚本与开机自启动[转]

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  3. 【转】Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设置相关参数,首先先介 ...

  4. redis 启动停止脚本

    redis 启动停止脚本,该redis需要密码登录,如没有密码,去掉stop函数里的 -a #!/bin/sh # #chkconfig: 2345 80 90 # Simple Redis init ...

  5. (转)Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  6. SpringBoot项目快速启动停止脚本

    SpringBoot项目快速启动停止脚本 1.在jar包同级目录下,创建 app.sh #!/bin/bash appName=`ls|grep .jar$` if [ -z $appName ] t ...

  7. win nginx + php bat启动/停止脚本

    启动脚本 @echo offREM Windows 下无效REM set PHP_FCGI_CHILDREN=5 REM 每个进程处理的最大请求数,或设置为 Windows 环境变量set PHP_F ...

  8. Bash Shell启动配置脚本的顺序

    1.Bash检查环境变量文件的方式,取决于系统运行Shell的方式,通常系统运行Shell有3种方式: )通过系统用户登陆后默认运行的Shell )非登陆交互式运行Shell )执行脚本运行非交互式S ...

  9. 微服务linux启动停止脚本

    # 停止脚本#!/bin/bash #其他服务停止脚步可以通过修改APP_MAIN参数即可 APP_MAIN=com.idoipo.infras.eureka.center.Application t ...

随机推荐

  1. vue-cli项目优化,缩短首屏加载时间

    1.大文件定位 我们可以使用webpack可视化插件Webpack Bundle Analyzer 查看工程js文件大小,然后有目的的解决过大的js文件. 安装:npm install --save- ...

  2. 关于ARM的B,BL跳转指令

    .text:00001260 A3 04 00 EB                             BL      sub_24F4 当前地址+ (偏移 << 2 + 8) =  ...

  3. 【PHP 】 伪静态 - 3. 伪静态的基本使用

    原理图: 原先浏览器输入的网址会发送到apache服务器,然后apache会调用php模块来处理,最后找到你所想访问的页面; 如果在apahce, httpd.conf文件中开启rewrite机制,则 ...

  4. JSTL详解(二)

    JSTL详解(二) 在JSTL中,一般用途的标签只要是指具有输出,设置变量,和错误处理等功能的标签,他们在jsp中使用很频繁,它们有: l         <c:out> l        ...

  5. MySQL Cluster配置文件-SQL节点4G内存

    # Example MySQL config file for large systems. # # This is for a large system with memory = 512M whe ...

  6. Js判断出生年月填写的 是否正确

    var r = /^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29 ...

  7. java各种框架的比较,分析

    Spring 框架 优点 1.提供了一种管理对象的方法,可以把中间层的对象有效地组织起来 2.采用了分层结构,可以增量引入到项目中. 3.代码测试较容易 4.非侵入性,应用程序对Spring API的 ...

  8. 类的专有方法(__len__)

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #http://www.imooc.com/code/6252 #类的专有方法(__len__) #如果一个类 ...

  9. 题目:vbs批量开通工具,实现vbs开通的ux设计和流程调度

    题目:vbs批量开通工具,实现vbs开通的ux设计和流程调度 需求点:支持开通前检查(检查失败不允许开站),开通过程监控,开通后业务检验,失败后重新开通,支持部分站点开通(比如用户导入的模板中有10个 ...

  10. PHP-各种下载安装

    Windows下常用PHP扩展下载: http://dev.freshsite.pl/php-accelerators.html http://windows.php.net/downloads/pe ...