Linux bash start stop script, second bomb

Source: Internet
Author: User
Tags auth stop script

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.