标签: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
标签:shell
原文地址:http://chentp.blog.51cto.com/10638759/1716825