Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following line in do_start() of my custom init script that starts a java application:

start-stop-daemon --background --start --quiet --oknodo --make-pidfile --pidfile $PIDFILE --chdir $SOLR_DIR --chuid $USER --exec $DAEMON -- \

when expanded, becomes:

start-stop-daemon --background --start --quiet --oknodo --make-pidfile --pidfile /var/run/ 
--chdir /home/phuihock/src/proj/solr 
--chuid phuihock 
--exec /usr/bin/java 
-- -jar start.jar >>/home/phuihock/src/proj/logs/solr.log 2>>/home/phuihock/src/proj/logs/solr.err

The log files created are owned by user root, group root. I'd expect they are owned by the user I set with --chuid, because from the manpage, everything after -- are passed unmodified.

My question is, are all redirects from start-stop-daemon owned by root, and is there a way to change that?

share|improve this question
up vote 2 down vote accepted

Redirections are not part of command line arguments. They are handled separately by the shell, which in your case is run as root. But even if the permissions were correct, this command wouldn't cause the output of the daemon to be appended to the log file.

For illustration, this is what actually happens:

  1. The shell executes start-stop-daemon and redirects its output to solr.log. The file is going to be empty, because this command doesn't output anything (just try running it manually, without redirection).
  2. The start-stop-daemon command processes its arguments and ends up calling /usr/bin/java -jar start.jar. Notice that there is no output redirection there, but the process is forked in the background, so the output ends up in /dev/null.

In other words, the daemon should either accept a log file argument, or you need to create a wrapper script that will handle the redirection. It might look as follows

cd /home/phuihock/src/proj/solr
exec /usr/bin/java -jar start.jar >> logs/solr.log
share|improve this answer
That solves the problem. Thanks! – phuihock Apr 18 '11 at 4:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.