首页 > 系统服务 > 详细

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

时间:2015-11-25 19:36:33      阅读:307      评论:0      收藏:0      [点我收藏+]

先贴效果:

技术分享

#!/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启动停止脚本,可以套用

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!