Logstash pid file

(shiva) #1

Hi All,

i'm starting my logstash with command ./logstash -f logstash.conf & as a backend process.
i would like to generate a pid file in my logstash home directory.
How to achieve this.

For kibana i have used pid.file in kibana.yml file.

Let me know if anyone has any pointers on this.


(Magnus B├Ąck) #2

The recommended way to run Logstash in the background is to run it as a service managed by systemd or whatever your operating system uses.

Logstash doesn't support pid files.

(shiva) #3

okay..let me try the systemd or other service..but my requirement is all the files related to ELK setup should be under the folder /opt/ELK/..

When i install filebeat as service....the filebeat.yml came up under etc/filebeat...

Hence checking for the other options...or is it possible to setup logstash as service but all the files under my custom folder i.e. /opt/ELK/..

currently i have a custom script which im using :
echo $sDate 'Start of Logstash' >> $LOG_FILE
echo $sDate 'Kill of Logstash' >> $LOG_FILE
logstashpid=lsof -i:9600 | grep 'LISTEN' | awk '{print $2}'

if [ -z '$logstashpid' ]
echo $sDate '$logstashpid is empty' >> $LOG_FILE
echo $sDate '$logstashpid is NOT empty' >> $LOG_FILE
echo $sDate 'logstashpid :'$logstashpid >> $LOG_FILE
kill -9 $logstashpid

cd /opt/ELK/logstash-6.4.0/bin
export JAVA_HOME=/opt/ELK/jdk
./logstash -f logstash.conf &

sleep 30

(shiva) #4

I was able to achieve my requirement with the use as systmectl. Below are the details.

under /etc/systemd/system i have created logstash.serivce with the below data :



and my logstash.sh contains:
dstamp=date '+%Y%m%d%H%M'
sDate=date '+%Y-%m-%d %r'

echo $sDate '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' >> $LOG_FILE

echo $sDate 'Start of Logstash' >> $LOG_FILE

cd /opt/ELK/logstash-6.4.0/bin
export JAVA_HOME=/opt/ELK/jdk
./logstash -f logstash.conf

echo $sDate 'END of Logstash' >> $LOG_FILE
echo $sDate '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' >> $LOG_FILE

(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.