Logstash Service startup script

Source: Internet
Author: User

Logstash Service startup script

Recently in the elk, found that Logstash no SYSV type of service startup script, so according to a foreigner provided by the online template to modify their own

#添加用户useradd Logstash-m-s/sbin/Nologinmkdir/var/log/logstash/Chown-R logstash:logstash/var/log/logstash/Chown-R logstash:logstash/usr/local/logstash-2.0.0/VI/etc/init.d/logstash#!/bin/bash#### BEGIN INIT info# provides:logstash# Required-Start: $local _fs $remote _fs# Required-Stop: $local _fs $remote _fs# Default-start:2 3 4 5# Default-stop:s0 1 6# Short-description:logstash# description:starts Logstash as a daemon.# Author: [email protected]### END INIT InfoSource 
    /etc/init.d/Functionssource/lib/lsb/init-functions# Process namename=Logstashdesc="Logstash Daemon"# Location of Logstash fileslocation="/usr/local/logstash-2.0.0/"#根据实际安装路径修改CONFIG_DIR="/usr/local/logstash-2.0.0/"LOGFILE="/var/log/logstash/logstash.log"ScriptName=/etc/init.d/Logstashpidfile="/var/run/logstash-agent.pid"Lock_file=/var/lock/subsys/$NAMENAMEJAVA=Javadaemonjava=`whichJava ' # ExitifThe package isn't installedif[!-X"$DAEMONJAVA"]; Then{  Echo "couldn ' t find $NAMEJAVA"Exit About}fistart () {Echo-N"starting $DESC:"        if["$ (PS aux|grep-e"*/usr/local/logstash*"|grep-v grep)"!=""]; Then             Echo "$desc already running ...."Exit0                     Else$LOCATION/bin/logstash-f $CONFIG _dir/logstash_agent.conf > $LOGFILE2>&1&RETVAL=$?Sleep 3        Echo            if["$ (PS aux|grep-e"*/usr/local/logstash*"|grep-v grep)"!=""]; Then                Echo "$DESC Started"[$RETVAL-eq0] &&Touch$LOCK _file return $RETVALfi                        fi}stop () {Echo-N $"Stop $DESC:"        Killall$NAMEJAVA RETVAL=$?Sleep 3        Echo        if["$ (PS aux|grep-eqi"*/usr/local/logstash*"|grep-v grep)"=""]; Then                Echo "$DESC stoped"[$RETVAL-eq0] &&RM-f/var/lock/subsys/$NAME $PIDFILE return $RETVALfi}restart () {Stop start} Case " $" inchstart) Start;  stop) stop;;  restart) restart;; Status) status $NAMEJAVA RETVAL=$?        ;; *)        Echo$"Usage: $ {start|stop|restart|status}"RETVAL=1EsacExit $RETVALEOFchmod+x/etc/init.d/logstash# Set Boot Chkconfig--add Logstashchkconfig logstash on

If there is a wrong place, welcome everyone to shoot brick O (∩_∩) o

The copyright of this article is owned by the author and cannot be reproduced without the author's consent.

Logstash Service startup script

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.