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

linux bash启动停止脚本,可以套用

时间:2015-11-25 19:37:03      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:shell

先贴效果:

技术分享

#!/bin/bash
#auth:chentp0601@qq.com
source /etc/init.d/functions
#判断参数个数
[ $# -ne 1 ]&&{
echo "usage:$0 {start|stop|restart|status}"
exit 1
}
#分支
case $1 in
start)
nohup watch -n 1 date "+%H:%M:%S" &> /tmp/date &
action "starting $0" /bin/true
;;
stop)
pkill watch
action "stoping $0" /bin/true
;;
restart)
pkill watch
nohup watch -n 1 date "+%H:%M:%S"  &> /tmp/date &
action "restarting $0" /bin/true
;;
status)
status=`ps -ef |grep -v grep|grep "watch -n"|wc -l`
[ $status -ne 0 ] && action "status of $0 is running" /bin/true||action "status of $0 is stoped" /bin/false
;;
*)
echo "usage:$0 {start|stop|restart|status}"
;;
esac


本文出自 “前进吧菜鸟” 博客,请务必保留此出处http://chentp.blog.51cto.com/10638759/1716825

linux bash启动停止脚本,可以套用

标签:shell

原文地址:http://chentp.blog.51cto.com/10638759/1716825

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