This article is an improvement of the shell script of the previous Watchdate Wdate, again first:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/76/95/wKioL1ZWwy_juP9NAARfY7_6zMo324.jpg "title=" Wdate " alt= "Wkiol1zwwy_jup9naarfy7_6zmo324.jpg"/>
1) script Join Chkconfig Management
head-5/etc/init.d/wdate
#!/bin/bash#auth:[email protected]# #wdate start/stop the watchdate daemon## chkconfig:2345 71 55
Chkconfig--add Wdate
2) Start pasting code
#!/bin/bash#auth:[email protected]# #wdate start/stop the watchdate daemon## chkconfig: 2345 71 55source /etc/init.d/ Functionsstartwdate () {nohup watch -n 1 date "+%h:%m:%s" &> /tmp/date &[ $? -eq 0 ] && action "Starting $0" /bin/true || action "starting $0" /bin/false}stopwdate () {pkill watch[ $? -eq 0 ] && action "Stoping $0" /bin/true| | action "stoping $0" /bin/false}statuswdate () {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} #判断参数个数 [ $# -ne 1 ] &&{echo "Usage:$0 {start|stop|restart|status}" exit 1} #分支case $1 instart) Startwdate;; stop) stopwdate;; restart) stopwdatestartwdate;; status) statuswdate;; *) echo "usage:$0 {start|stop|restart|status}";; Esac
This article is from the "Advance Bar Rookie" blog, please make sure to keep this source http://chentp.blog.51cto.com/10638759/1717141
Linux bash start stop script, second bomb