# Logstash 1.4.0 debian package init script not working

**URL:** <https://discuss.elastic.co/t/logstash-1-4-0-debian-package-init-script-not-working/17070>\
**Category:** Elasticsearch\
**Created:** [April 18, 2014, 1:12am UTC](https://discuss.elastic.co/t/logstash-1-4-0-debian-package-init-script-not-working/17070 "2014-04-18T01:12:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![OJ\_LaBoeuf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oj_laboeuf/32/1638_2.png) [@OJ\_LaBoeuf](https://discuss.elastic.co/u/OJ_LaBoeuf)\
**Post date:** [April 18, 2014, 1:12am UTC](https://discuss.elastic.co/t/logstash-1-4-0-debian-package-init-script-not-working/17070/1 "2014-04-18T01:12:38Z")

</div>

Running Ubuntu 12.04 64bit, the logstash init script does not work.

here's the script that came with logstash deb

In particular I don't understand how the script is trying to parse  
something from the logstash pid, before it even starts the program..?

```
  log_daemon_msg "Starting $DESC"

  # Parse the actual JAVACMD from the process' environment, we don't 

```

care about errors.  
JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ 2\>/dev/null  
| grep -z ^JAVACMD= | cut -d= -f2)  
if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
--user "$LS\_USER" --exec "$JAVA"   
\>/dev/null; then  
# Prepare environment

I checked and JAVA is empty at this location, so what the heck is this  
trying to do?

running this bit:  
sudo start-stop-daemon --test --start --pidfile /var/run/logstash.pid  
--user "logstash" --exec ""

results in the same message i get at the commandline when trying to  
/etc/init.d/logstash start  
start-stop-daemon: unable to stat (No such file or directory)

Please advise.

Full init script pasted below

#!/bin/bash

# 

# /etc/init.d/logstash -- startup script for LogStash.

# 

### BEGIN INIT INFO

# Provides: logstash

# Required-Start: $all

# Required-Stop: $all

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: Starts logstash

# Description: Starts logstash using start-stop-daemon

### END INIT INFO

set -e

NAME=logstash  
DESC="Logstash Daemon"  
DEFAULT=/etc/default/$NAME

if [`id -u` -ne 0]; then  
echo "You need root privileges to run this script"  
exit 1  
fi

. /lib/lsb/init-functions

if [-r /etc/default/rcS]; then  
. /etc/default/rcS  
fi

# The following variables can be overwritten in $DEFAULT

PATH=/bin:/usr/bin:/sbin:/usr/sbin

# See contents of file named in $DEFAULT for comments

LS\_USER=logstash  
LS\_GROUP=logstash  
LS\_HOME=/var/lib/logstash  
LS\_HEAP\_SIZE="500m"  
LS\_JAVA\_OPTS="-Djava.io.tmpdir=${LS\_HOME}"  
LS\_LOG\_FILE=/var/log/logstash/$NAME.log  
LS\_CONF\_DIR=/etc/logstash/conf.d  
LS\_OPEN\_FILES=16384  
LS\_NICE=19  
LS\_OPTS=""  
LS\_PIDFILE=/var/run/$NAME.pid

# End of variables that can be overwritten in $DEFAULT

# overwrite settings from default file

if [-f "$DEFAULT"]; then  
. "$DEFAULT"  
fi

# Define other required variables

PID\_FILE=${LS\_PIDFILE}  
DAEMON=/opt/logstash/bin/logstash  
DAEMON\_OPTS="agent -f ${LS\_CONF\_DIR} -l ${LS\_LOG\_FILE} ${LS\_OPTS}"

# Check DAEMON exists

if ! test -e $DAEMON; then  
log\_failure\_msg "Script $DAEMON doesn't exist"  
exit 1  
fi

case "$1" in  
start)  
if [-z "$DAEMON"]; then  
log\_failure\_msg "no logstash script found - $DAEMON"  
exit 1  
fi

```
  # Check if a config file exists
  if [! "$(ls -A $LS_CONF_DIR/*.conf 2> /dev/null)"]; then
     log_failure_msg "There aren't any configuration files in 

```

$LS\_CONF\_DIR"  
exit 1  
fi

```
  log_daemon_msg "Starting $DESC"

  # Parse the actual JAVACMD from the process' environment, we don't 

```

care about errors.  
JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ 2\>/dev/null  
| grep -z ^JAVACMD= | cut -d= -f2)  
if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
--user "$LS\_USER" --exec "$JAVA"   
\>/dev/null; then  
# Prepare environment  
HOME="${HOME:-$LS\_HOME}"  
JAVA\_OPTS="${LS\_JAVA\_OPTS}"  
ulimit -n ${LS\_OPEN\_FILES}  
cd "${LS\_HOME}"  
export PATH HOME JAVACMD JAVA\_OPTS LS\_HEAP\_SIZE LS\_JAVA\_OPTS  
LS\_USE\_GC\_LOGGING

```
     # Start Daemon
     start-stop-daemon --start -b --user "$LS_USER" -c 

```

"$LS\_USER":"$LS\_GROUP"   
-d "$LS\_HOME" --nicelevel "$LS\_NICE" --pidfile "$PID\_FILE"  
--make-pidfile   
--exec $DAEMON -- $DAEMON\_OPTS

```
     sleep 1

     # Parse the actual JAVACMD from the process' environment, we don't 

```

care about errors.  
JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
--user "$LS\_USER" --exec "$JAVA"   
\>/dev/null; then

```
        if [-f "$PID_FILE"]; then
           rm -f "$PID_FILE"
        fi

        log_end_msg 1
     else
        log_end_msg 0
     fi
  else
     log_progress_msg "(already running)"
     log_end_msg 0
  fi

```

;;  
stop)  
log\_daemon\_msg "Stopping $DESC"

```
  set +e

  if [-f "$PID_FILE"]; then
     start-stop-daemon --stop --pidfile "$PID_FILE" \
        --user "$LS_USER" \
        --retry=TERM/20/KILL/5 >/dev/null

     if [$? -eq 1]; then
        log_progress_msg "$DESC is not running but pid file exists, 

```

cleaning up"  
elif [$? -eq 3]; then  
PID="`cat $PID_FILE`"  
log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
exit 1  
fi

```
     rm -f "$PID_FILE"
  else
     log_progress_msg "(not running)"
  fi

  log_end_msg 0
  set -e

```

;;  
status)  
set +e

```
  # Parse the actual JAVACMD from the process' environment, we don't 

```

care about errors.  
JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ 2\>/dev/null  
| grep -z ^JAVACMD= | cut -d= -f2)  
start-stop-daemon --test --start --pidfile "$PID\_FILE"   
--user "$LS\_USER" --exec "$JAVA"   
\>/dev/null 2\>&1

```
  if ["$?" = "0"]; then
     if [-f "$PID_FILE"]; then
        log_success_msg "$DESC is not running, but pid file exists."
        exit 1
     else
        log_success_msg "$DESC is not running."
        exit 3
     fi
  else
     log_success_msg "$DESC is running with pid `cat $PID_FILE`"
  fi

  set -e

```

;;  
restart|force-reload)  
if [-f "$PID\_FILE"]; then  
$0 stop  
sleep 1  
fi

```
  $0 start

```

;;  
\*)  
log\_success\_msg "Usage: $0 {start|stop|restart|force-reload|status}"  
exit 1  
;;  
esac

exit 0

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fc7145b3-7259-41d9-8f9b-22139edde3b6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fc7145b3-7259-41d9-8f9b-22139edde3b6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![OJ\_LaBoeuf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oj_laboeuf/32/1638_2.png) [@OJ\_LaBoeuf](https://discuss.elastic.co/u/OJ_LaBoeuf)\
**Post date:** [April 18, 2014, 4:36am UTC](https://discuss.elastic.co/t/logstash-1-4-0-debian-package-init-script-not-working/17070/2 "2014-04-18T04:36:51Z")

</div>

The upstart job also doesn't seem to work, it just keeps dying over and  
over again never logging anything to the logfile.

If i manually start logstash everything works normally.

On Thursday, April 17, 2014 6:12:38 PM UTC-7, OJ LaBoeuf wrote:

> Running Ubuntu 12.04 64bit, the logstash init script does not work.
> 
> here's the script that came with logstash deb
> 
> In particular I don't understand how the script is trying to parse  
> something from the logstash pid, before it even starts the program..?
> 
> ```
> log_daemon_msg "Starting $DESC"
> 
> # Parse the actual JAVACMD from the process' environment, we don't 
> 
> ```
> 
> care about errors.  
> JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> --user "$LS\_USER" --exec "$JAVA"   
> \>/dev/null; then  
> # Prepare environment
> 
> I checked and JAVA is empty at this location, so what the heck is this  
> trying to do?
> 
> running this bit:  
> sudo start-stop-daemon --test --start --pidfile /var/run/logstash.pid  
> --user "logstash" --exec ""
> 
> results in the same message i get at the commandline when trying to  
> /etc/init.d/logstash start  
> start-stop-daemon: unable to stat (No such file or directory)
> 
> Please advise.
> 
> Full init script pasted below
> 
> #!/bin/bash
> 
> # 
> 
> # /etc/init.d/logstash -- startup script for LogStash.
> 
> # 
> 
> ### BEGIN INIT INFO
> 
> # Provides: logstash
> 
> # Required-Start: $all
> 
> # Required-Stop: $all
> 
> # Default-Start: 2 3 4 5
> 
> # Default-Stop: 0 1 6
> 
> # Short-Description: Starts logstash
> 
> # Description: Starts logstash using start-stop-daemon
> 
> ### END INIT INFO
> 
> set -e
> 
> NAME=logstash  
> DESC="Logstash Daemon"  
> DEFAULT=/etc/default/$NAME
> 
> if [`id -u` -ne 0]; then  
> echo "You need root privileges to run this script"  
> exit 1  
> fi
> 
> . /lib/lsb/init-functions
> 
> if [-r /etc/default/rcS]; then  
> . /etc/default/rcS  
> fi
> 
> # The following variables can be overwritten in $DEFAULT
> 
> PATH=/bin:/usr/bin:/sbin:/usr/sbin
> 
> # See contents of file named in $DEFAULT for comments
> 
> LS\_USER=logstash  
> LS\_GROUP=logstash  
> LS\_HOME=/var/lib/logstash  
> LS\_HEAP\_SIZE="500m"  
> LS\_JAVA\_OPTS="-Djava.io.tmpdir=${LS\_HOME}"  
> LS\_LOG\_FILE=/var/log/logstash/$NAME.log  
> LS\_CONF\_DIR=/etc/logstash/conf.d  
> LS\_OPEN\_FILES=16384  
> LS\_NICE=19  
> LS\_OPTS=""  
> LS\_PIDFILE=/var/run/$NAME.pid
> 
> # End of variables that can be overwritten in $DEFAULT
> 
> # overwrite settings from default file
> 
> if [-f "$DEFAULT"]; then  
> . "$DEFAULT"  
> fi
> 
> # Define other required variables
> 
> PID\_FILE=${LS\_PIDFILE}  
> DAEMON=/opt/logstash/bin/logstash  
> DAEMON\_OPTS="agent -f ${LS\_CONF\_DIR} -l ${LS\_LOG\_FILE} ${LS\_OPTS}"
> 
> # Check DAEMON exists
> 
> if ! test -e $DAEMON; then  
> log\_failure\_msg "Script $DAEMON doesn't exist"  
> exit 1  
> fi
> 
> case "$1" in  
> start)  
> if [-z "$DAEMON"]; then  
> log\_failure\_msg "no logstash script found - $DAEMON"  
> exit 1  
> fi
> 
> ```
> # Check if a config file exists
> if [! "$(ls -A $LS_CONF_DIR/*.conf 2> /dev/null)"]; then
> log_failure_msg "There aren't any configuration files in 
> 
> ```
> 
> $LS\_CONF\_DIR"  
> exit 1  
> fi
> 
> ```
> log_daemon_msg "Starting $DESC"
> 
> # Parse the actual JAVACMD from the process' environment, we don't 
> 
> ```
> 
> care about errors.  
> JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> --user "$LS\_USER" --exec "$JAVA"   
> \>/dev/null; then  
> # Prepare environment  
> HOME="${HOME:-$LS\_HOME}"  
> JAVA\_OPTS="${LS\_JAVA\_OPTS}"  
> ulimit -n ${LS\_OPEN\_FILES}  
> cd "${LS\_HOME}"  
> export PATH HOME JAVACMD JAVA\_OPTS LS\_HEAP\_SIZE LS\_JAVA\_OPTS  
> LS\_USE\_GC\_LOGGING
> 
> ```
> # Start Daemon
> start-stop-daemon --start -b --user "$LS_USER" -c 
> 
> ```
> 
> "$LS\_USER":"$LS\_GROUP"   
> -d "$LS\_HOME" --nicelevel "$LS\_NICE" --pidfile "$PID\_FILE"  
> --make-pidfile   
> --exec $DAEMON -- $DAEMON\_OPTS
> 
> ```
> sleep 1
> 
> # Parse the actual JAVACMD from the process' environment, we 
> 
> ```
> 
> don't care about errors.  
> JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> --user "$LS\_USER" --exec "$JAVA"   
> \>/dev/null; then
> 
> ```
> if [-f "$PID_FILE"]; then
> rm -f "$PID_FILE"
> fi
> 
> log_end_msg 1
> else
> log_end_msg 0
> fi
> else
> log_progress_msg "(already running)"
> log_end_msg 0
> fi
> 
> ```
> 
> ;;  
> stop)  
> log\_daemon\_msg "Stopping $DESC"
> 
> ```
> set +e
> 
> if [-f "$PID_FILE"]; then
> start-stop-daemon --stop --pidfile "$PID_FILE" \
> --user "$LS_USER" \
> --retry=TERM/20/KILL/5 >/dev/null
> 
> if [$? -eq 1]; then
> log_progress_msg "$DESC is not running but pid file exists, 
> 
> ```
> 
> cleaning up"  
> elif [$? -eq 3]; then  
> PID="`cat $PID_FILE`"  
> log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
> exit 1  
> fi
> 
> ```
> rm -f "$PID_FILE"
> else
> log_progress_msg "(not running)"
> fi
> 
> log_end_msg 0
> set -e
> 
> ```
> 
> ;;  
> status)  
> set +e
> 
> ```
> # Parse the actual JAVACMD from the process' environment, we don't 
> 
> ```
> 
> care about errors.  
> JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> --user "$LS\_USER" --exec "$JAVA"   
> \>/dev/null 2\>&1
> 
> ```
> if ["$?" = "0"]; then
> if [-f "$PID_FILE"]; then
> log_success_msg "$DESC is not running, but pid file exists."
> exit 1
> else
> log_success_msg "$DESC is not running."
> exit 3
> fi
> else
> log_success_msg "$DESC is running with pid `cat $PID_FILE`"
> fi
> 
> set -e
> 
> ```
> 
> ;;  
> restart|force-reload)  
> if [-f "$PID\_FILE"]; then  
> $0 stop  
> sleep 1  
> fi
> 
> ```
> $0 start
> 
> ```
> 
> ;;  
> \*)  
> log\_success\_msg "Usage: $0 {start|stop|restart|force-reload|status}"  
> exit 1  
> ;;  
> esac
> 
> exit 0

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f890b799-5ac0-408e-bc75-2651677a0503%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f890b799-5ac0-408e-bc75-2651677a0503%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Goofy03](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@Goofy03](https://discuss.elastic.co/u/Goofy03)\
**Post date:** [April 18, 2014, 2:48pm UTC](https://discuss.elastic.co/t/logstash-1-4-0-debian-package-init-script-not-working/17070/3 "2014-04-18T14:48:06Z")

</div>

Do you have check permission on /opt/logstash and /var/log/logstash  
/etc/logstash … same user than in the init script ?

Solve this for me on debian but i can't get event when apache log is  
update. than if i run it in root (console way) all is working …  
Ho and i have add logstash user to adm group …

Le vendredi 18 avril 2014 06:36:51 UTC+2, OJ LaBoeuf a écrit :

> The upstart job also doesn't seem to work, it just keeps dying over and  
> over again never logging anything to the logfile.
> 
> If i manually start logstash everything works normally.
> 
> On Thursday, April 17, 2014 6:12:38 PM UTC-7, OJ LaBoeuf wrote:
> 
> > Running Ubuntu 12.04 64bit, the logstash init script does not work.
> > 
> > here's the script that came with logstash deb
> > 
> > In particular I don't understand how the script is trying to parse  
> > something from the logstash pid, before it even starts the program..?
> > 
> > ```
> > log_daemon_msg "Starting $DESC"
> > 
> > # Parse the actual JAVACMD from the process' environment, we don't 
> > 
> > ```
> > 
> > care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null; then  
> > # Prepare environment
> > 
> > I checked and JAVA is empty at this location, so what the heck is this  
> > trying to do?
> > 
> > running this bit:  
> > sudo start-stop-daemon --test --start --pidfile /var/run/logstash.pid  
> > --user "logstash" --exec ""
> > 
> > results in the same message i get at the commandline when trying to  
> > /etc/init.d/logstash start  
> > start-stop-daemon: unable to stat (No such file or directory)
> > 
> > Please advise.
> > 
> > Full init script pasted below
> > 
> > #!/bin/bash
> > 
> > # 
> > 
> > # /etc/init.d/logstash -- startup script for LogStash.
> > 
> > # 
> > 
> > ### BEGIN INIT INFO
> > 
> > # Provides: logstash
> > 
> > # Required-Start: $all
> > 
> > # Required-Stop: $all
> > 
> > # Default-Start: 2 3 4 5
> > 
> > # Default-Stop: 0 1 6
> > 
> > # Short-Description: Starts logstash
> > 
> > # Description: Starts logstash using start-stop-daemon
> > 
> > ### END INIT INFO
> > 
> > set -e
> > 
> > NAME=logstash  
> > DESC="Logstash Daemon"  
> > DEFAULT=/etc/default/$NAME
> > 
> > if [`id -u` -ne 0]; then  
> > echo "You need root privileges to run this script"  
> > exit 1  
> > fi
> > 
> > . /lib/lsb/init-functions
> > 
> > if [-r /etc/default/rcS]; then  
> > . /etc/default/rcS  
> > fi
> > 
> > # The following variables can be overwritten in $DEFAULT
> > 
> > PATH=/bin:/usr/bin:/sbin:/usr/sbin
> > 
> > # See contents of file named in $DEFAULT for comments
> > 
> > LS\_USER=logstash  
> > LS\_GROUP=logstash  
> > LS\_HOME=/var/lib/logstash  
> > LS\_HEAP\_SIZE="500m"  
> > LS\_JAVA\_OPTS="-Djava.io.tmpdir=${LS\_HOME}"  
> > LS\_LOG\_FILE=/var/log/logstash/$NAME.log  
> > LS\_CONF\_DIR=/etc/logstash/conf.d  
> > LS\_OPEN\_FILES=16384  
> > LS\_NICE=19  
> > LS\_OPTS=""  
> > LS\_PIDFILE=/var/run/$NAME.pid
> > 
> > # End of variables that can be overwritten in $DEFAULT
> > 
> > # overwrite settings from default file
> > 
> > if [-f "$DEFAULT"]; then  
> > . "$DEFAULT"  
> > fi
> > 
> > # Define other required variables
> > 
> > PID\_FILE=${LS\_PIDFILE}  
> > DAEMON=/opt/logstash/bin/logstash  
> > DAEMON\_OPTS="agent -f ${LS\_CONF\_DIR} -l ${LS\_LOG\_FILE} ${LS\_OPTS}"
> > 
> > # Check DAEMON exists
> > 
> > if ! test -e $DAEMON; then  
> > log\_failure\_msg "Script $DAEMON doesn't exist"  
> > exit 1  
> > fi
> > 
> > case "$1" in  
> > start)  
> > if [-z "$DAEMON"]; then  
> > log\_failure\_msg "no logstash script found - $DAEMON"  
> > exit 1  
> > fi
> > 
> > ```
> > # Check if a config file exists
> > if [! "$(ls -A $LS_CONF_DIR/*.conf 2> /dev/null)"]; then
> > log_failure_msg "There aren't any configuration files in 
> > 
> > ```
> > 
> > $LS\_CONF\_DIR"  
> > exit 1  
> > fi
> > 
> > ```
> > log_daemon_msg "Starting $DESC"
> > 
> > # Parse the actual JAVACMD from the process' environment, we don't 
> > 
> > ```
> > 
> > care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null; then  
> > # Prepare environment  
> > HOME="${HOME:-$LS\_HOME}"  
> > JAVA\_OPTS="${LS\_JAVA\_OPTS}"  
> > ulimit -n ${LS\_OPEN\_FILES}  
> > cd "${LS\_HOME}"  
> > export PATH HOME JAVACMD JAVA\_OPTS LS\_HEAP\_SIZE LS\_JAVA\_OPTS  
> > LS\_USE\_GC\_LOGGING
> > 
> > ```
> > # Start Daemon
> > start-stop-daemon --start -b --user "$LS_USER" -c 
> > 
> > ```
> > 
> > "$LS\_USER":"$LS\_GROUP"   
> > -d "$LS\_HOME" --nicelevel "$LS\_NICE" --pidfile "$PID\_FILE"  
> > --make-pidfile   
> > --exec $DAEMON -- $DAEMON\_OPTS
> > 
> > ```
> > sleep 1
> > 
> > # Parse the actual JAVACMD from the process' environment, we 
> > 
> > ```
> > 
> > don't care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null; then
> > 
> > ```
> > if [-f "$PID_FILE"]; then
> > rm -f "$PID_FILE"
> > fi
> > 
> > log_end_msg 1
> > else
> > log_end_msg 0
> > fi
> > else
> > log_progress_msg "(already running)"
> > log_end_msg 0
> > fi
> > 
> > ```
> > 
> > ;;  
> > stop)  
> > log\_daemon\_msg "Stopping $DESC"
> > 
> > ```
> > set +e
> > 
> > if [-f "$PID_FILE"]; then
> > start-stop-daemon --stop --pidfile "$PID_FILE" \
> > --user "$LS_USER" \
> > --retry=TERM/20/KILL/5 >/dev/null
> > 
> > if [$? -eq 1]; then
> > log_progress_msg "$DESC is not running but pid file exists, 
> > 
> > ```
> > 
> > cleaning up"  
> > elif [$? -eq 3]; then  
> > PID="`cat $PID_FILE`"  
> > log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
> > exit 1  
> > fi
> > 
> > ```
> > rm -f "$PID_FILE"
> > else
> > log_progress_msg "(not running)"
> > fi
> > 
> > log_end_msg 0
> > set -e
> > 
> > ```
> > 
> > ;;  
> > status)  
> > set +e
> > 
> > ```
> > # Parse the actual JAVACMD from the process' environment, we don't 
> > 
> > ```
> > 
> > care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null 2\>&1
> > 
> > ```
> > if ["$?" = "0"]; then
> > if [-f "$PID_FILE"]; then
> > log_success_msg "$DESC is not running, but pid file exists."
> > exit 1
> > else
> > log_success_msg "$DESC is not running."
> > exit 3
> > fi
> > else
> > log_success_msg "$DESC is running with pid `cat $PID_FILE`"
> > fi
> > 
> > set -e
> > 
> > ```
> > 
> > ;;  
> > restart|force-reload)  
> > if [-f "$PID\_FILE"]; then  
> > $0 stop  
> > sleep 1  
> > fi
> > 
> > ```
> > $0 start
> > 
> > ```
> > 
> > ;;  
> > \*)  
> > log\_success\_msg "Usage: $0 {start|stop|restart|force-reload|status}"  
> > exit 1  
> > ;;  
> > esac
> > 
> > exit 0

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/031a2344-4533-4c34-be2d-0d29f046c05e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/031a2344-4533-4c34-be2d-0d29f046c05e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Paolo\_Peruggini](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@Paolo\_Peruggini](https://discuss.elastic.co/u/Paolo_Peruggini)\
**Post date:** [April 29, 2014, 1:33pm UTC](https://discuss.elastic.co/t/logstash-1-4-0-debian-package-init-script-not-working/17070/4 "2014-04-29T13:33:35Z")

</div>

Hi,  
same problem for me, I modified original script.  
Please try with this version: [http://hastebin.com/uwiqasuyul.bash](http://hastebin.com/uwiqasuyul.bash)

Il giorno venerdì 18 aprile 2014 06:36:51 UTC+2, OJ LaBoeuf ha scritto:

> The upstart job also doesn't seem to work, it just keeps dying over and  
> over again never logging anything to the logfile.
> 
> If i manually start logstash everything works normally.
> 
> On Thursday, April 17, 2014 6:12:38 PM UTC-7, OJ LaBoeuf wrote:
> 
> > Running Ubuntu 12.04 64bit, the logstash init script does not work.
> > 
> > here's the script that came with logstash deb
> > 
> > In particular I don't understand how the script is trying to parse  
> > something from the logstash pid, before it even starts the program..?
> > 
> > ```
> > log_daemon_msg "Starting $DESC"
> > 
> > # Parse the actual JAVACMD from the process' environment, we don't 
> > 
> > ```
> > 
> > care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null; then  
> > # Prepare environment
> > 
> > I checked and JAVA is empty at this location, so what the heck is this  
> > trying to do?
> > 
> > running this bit:  
> > sudo start-stop-daemon --test --start --pidfile /var/run/logstash.pid  
> > --user "logstash" --exec ""
> > 
> > results in the same message i get at the commandline when trying to  
> > /etc/init.d/logstash start  
> > start-stop-daemon: unable to stat (No such file or directory)
> > 
> > Please advise.
> > 
> > Full init script pasted below
> > 
> > #!/bin/bash
> > 
> > # 
> > 
> > # /etc/init.d/logstash -- startup script for LogStash.
> > 
> > # 
> > 
> > ### BEGIN INIT INFO
> > 
> > # Provides: logstash
> > 
> > # Required-Start: $all
> > 
> > # Required-Stop: $all
> > 
> > # Default-Start: 2 3 4 5
> > 
> > # Default-Stop: 0 1 6
> > 
> > # Short-Description: Starts logstash
> > 
> > # Description: Starts logstash using start-stop-daemon
> > 
> > ### END INIT INFO
> > 
> > set -e
> > 
> > NAME=logstash  
> > DESC="Logstash Daemon"  
> > DEFAULT=/etc/default/$NAME
> > 
> > if [`id -u` -ne 0]; then  
> > echo "You need root privileges to run this script"  
> > exit 1  
> > fi
> > 
> > . /lib/lsb/init-functions
> > 
> > if [-r /etc/default/rcS]; then  
> > . /etc/default/rcS  
> > fi
> > 
> > # The following variables can be overwritten in $DEFAULT
> > 
> > PATH=/bin:/usr/bin:/sbin:/usr/sbin
> > 
> > # See contents of file named in $DEFAULT for comments
> > 
> > LS\_USER=logstash  
> > LS\_GROUP=logstash  
> > LS\_HOME=/var/lib/logstash  
> > LS\_HEAP\_SIZE="500m"  
> > LS\_JAVA\_OPTS="-Djava.io.tmpdir=${LS\_HOME}"  
> > LS\_LOG\_FILE=/var/log/logstash/$NAME.log  
> > LS\_CONF\_DIR=/etc/logstash/conf.d  
> > LS\_OPEN\_FILES=16384  
> > LS\_NICE=19  
> > LS\_OPTS=""  
> > LS\_PIDFILE=/var/run/$NAME.pid
> > 
> > # End of variables that can be overwritten in $DEFAULT
> > 
> > # overwrite settings from default file
> > 
> > if [-f "$DEFAULT"]; then  
> > . "$DEFAULT"  
> > fi
> > 
> > # Define other required variables
> > 
> > PID\_FILE=${LS\_PIDFILE}  
> > DAEMON=/opt/logstash/bin/logstash  
> > DAEMON\_OPTS="agent -f ${LS\_CONF\_DIR} -l ${LS\_LOG\_FILE} ${LS\_OPTS}"
> > 
> > # Check DAEMON exists
> > 
> > if ! test -e $DAEMON; then  
> > log\_failure\_msg "Script $DAEMON doesn't exist"  
> > exit 1  
> > fi
> > 
> > case "$1" in  
> > start)  
> > if [-z "$DAEMON"]; then  
> > log\_failure\_msg "no logstash script found - $DAEMON"  
> > exit 1  
> > fi
> > 
> > ```
> > # Check if a config file exists
> > if [! "$(ls -A $LS_CONF_DIR/*.conf 2> /dev/null)"]; then
> > log_failure_msg "There aren't any configuration files in 
> > 
> > ```
> > 
> > $LS\_CONF\_DIR"  
> > exit 1  
> > fi
> > 
> > ```
> > log_daemon_msg "Starting $DESC"
> > 
> > # Parse the actual JAVACMD from the process' environment, we don't 
> > 
> > ```
> > 
> > care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null; then  
> > # Prepare environment  
> > HOME="${HOME:-$LS\_HOME}"  
> > JAVA\_OPTS="${LS\_JAVA\_OPTS}"  
> > ulimit -n ${LS\_OPEN\_FILES}  
> > cd "${LS\_HOME}"  
> > export PATH HOME JAVACMD JAVA\_OPTS LS\_HEAP\_SIZE LS\_JAVA\_OPTS  
> > LS\_USE\_GC\_LOGGING
> > 
> > ```
> > # Start Daemon
> > start-stop-daemon --start -b --user "$LS_USER" -c 
> > 
> > ```
> > 
> > "$LS\_USER":"$LS\_GROUP"   
> > -d "$LS\_HOME" --nicelevel "$LS\_NICE" --pidfile "$PID\_FILE"  
> > --make-pidfile   
> > --exec $DAEMON -- $DAEMON\_OPTS
> > 
> > ```
> > sleep 1
> > 
> > # Parse the actual JAVACMD from the process' environment, we 
> > 
> > ```
> > 
> > don't care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > if start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null; then
> > 
> > ```
> > if [-f "$PID_FILE"]; then
> > rm -f "$PID_FILE"
> > fi
> > 
> > log_end_msg 1
> > else
> > log_end_msg 0
> > fi
> > else
> > log_progress_msg "(already running)"
> > log_end_msg 0
> > fi
> > 
> > ```
> > 
> > ;;  
> > stop)  
> > log\_daemon\_msg "Stopping $DESC"
> > 
> > ```
> > set +e
> > 
> > if [-f "$PID_FILE"]; then
> > start-stop-daemon --stop --pidfile "$PID_FILE" \
> > --user "$LS_USER" \
> > --retry=TERM/20/KILL/5 >/dev/null
> > 
> > if [$? -eq 1]; then
> > log_progress_msg "$DESC is not running but pid file exists, 
> > 
> > ```
> > 
> > cleaning up"  
> > elif [$? -eq 3]; then  
> > PID="`cat $PID_FILE`"  
> > log\_failure\_msg "Failed to stop $DESC (pid $PID)"  
> > exit 1  
> > fi
> > 
> > ```
> > rm -f "$PID_FILE"
> > else
> > log_progress_msg "(not running)"
> > fi
> > 
> > log_end_msg 0
> > set -e
> > 
> > ```
> > 
> > ;;  
> > status)  
> > set +e
> > 
> > ```
> > # Parse the actual JAVACMD from the process' environment, we don't 
> > 
> > ```
> > 
> > care about errors.  
> > JAVA=$(cat /proc/$(cat "${PID\_FILE}" 2\>/dev/null)/environ  
> > 2\>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)  
> > start-stop-daemon --test --start --pidfile "$PID\_FILE"   
> > --user "$LS\_USER" --exec "$JAVA"   
> > \>/dev/null 2\>&1
> > 
> > ```
> > if ["$?" = "0"]; then
> > if [-f "$PID_FILE"]; then
> > log_success_msg "$DESC is not running, but pid file exists."
> > exit 1
> > else
> > log_success_msg "$DESC is not running."
> > exit 3
> > fi
> > else
> > log_success_msg "$DESC is running with pid `cat $PID_FILE`"
> > fi
> > 
> > set -e
> > 
> > ```
> > 
> > ;;  
> > restart|force-reload)  
> > if [-f "$PID\_FILE"]; then  
> > $0 stop  
> > sleep 1  
> > fi
> > 
> > ```
> > $0 start
> > 
> > ```
> > 
> > ;;  
> > \*)  
> > log\_success\_msg "Usage: $0 {start|stop|restart|force-reload|status}"  
> > exit 1  
> > ;;  
> > esac
> > 
> > exit 0

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/992c72f4-f75f-4dda-809f-2e15d4aece83%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/992c72f4-f75f-4dda-809f-2e15d4aece83%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:32am UTC](https://discuss.elastic.co/t/logstash-1-4-0-debian-package-init-script-not-working/17070/5 "2017-07-06T01:32:45Z")

</div>


