Apply random boot on Linux

Source: Internet
Author: User
Tags syslog etcd

This is a go project, others can be consulted.

The first thing to do is to have a script like demo

#!/bin/bash## Etcd This shell script takes care of starting and stopping etcd## Chkconfig:2345  the  -# # # BEGIN INIT info# provides:etcd# Required-Start: $network $syslog # Required-Stop: $network $syslog # Default-start:# Default-stop:# Short-Description:start and stop etcd### END INIT INFO # # Source function library.#./etc/rc.d/init.d/Functionsexport Java_home=/Usrexport PATH= $JAVA _home/Bin: $PATHGOPATH=/opt/etcdrepo/Etcdetcd_home=$GOPATHEtcd_pid () {echo ' PS aux| Grep"etcd\>"| Grep-v grep | Awk'{print $}'| Tail-n1'} start () {PID=$ (etcd_pid)if[-N"$pid"] then echo"Etcd is already running (PID: $pid)"    Else#Start Etcd Echo"starting ETCD"Ulimit-N100000umask007sudo $ETCD _home/bin/etcd-data-dir machines/machine1-name Machine1 & >Log.txt fireturn 0} stop () {PID=$ (etcd_pid)if[-N"$pid"] then echo-n-e"\nkilling processes which didn ' t stop after $SHUTDOWN _wait seconds"Kill-9$pidElseEcho"Etcd is not running"fireturn 0}  Case$1 inchstart) Start; stop) stop;; restart) stop start;; status) PID=$ (etcd_pid)if[-N"$pid"] then echo"Etcd is running with PID: $pid"    ElseEcho"Etcd is not running"fi;; Esacexit0

2. Put this script under/ETC/INIT.D or/ETC/RC.D/INIT.D

3. Set permissions

sudo chmod 777 Demosudo chkconfig--add demosudo chkconfig--list Demosudo Service Demo start  when the service is not found  

4. Reboot Linux Try it!

Apply random boot on Linux

Related Article

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.