码迷,mamicode.com
首页 > 系统相关 > 详细

shell拉进程

时间:2015-07-02 17:50:12      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:shell

#!/bin/sh
MM=`ps -ef|grep memcached|grep -v grep|wc -l`
while [ "$MM" -eq 0 ]
   do
   echo "$(date +%Y%m%d%H%M%S),the memcached is down,try to up it" >>/data/shell/men.log
   /usr/bin/memcached -d -u root -m 512 -p 39999 -c 1024
   sleep 2s
   MM=`ps -ef|grep memcached|grep -v grep|wc -l`
   done
   echo "$(date +%Y%m%d%H%M%S),the memcached is ok" >>/data/shell/men.log


使用ps 统计进程数,如果为零。则拉起程序

并记录log

date 用法参考http://www.cnblogs.com/peida/archive/2012/12/13/2815687.html

shell拉进程

标签:shell

原文地址:http://youngcloud.blog.51cto.com/2873694/1670070

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!