title: Log output from service in /var/log/<service-name> (sysvinit)
body: <p>I have an <code>init.d</code> script that runs a binary as a daemon. The binary regularly writes status lines to stdout. I would like to log those lines into <code>/var/log/my-daemon</code>.</p>
  <p>When the start code is like this:</p>
  <pre><code>start-stop-daemon -S -x $DAEMON -- $ARGS
  </code></pre>
  <p>And I run <code>service my-daemon restart</code>, then I get the log output on... stdout. But obviously, I want to run it in background, and save the logs to a file.</p>
  <p>I want something like this (inspired by <a href="https://stackoverflow.com/questions/8251933/how-can-i-log-the-stdout-of-a-process-started-by-start-stop-daemon">this</a>):</p>
  <pre><code>start-stop-daemon -S --background -x $DAEMON -- $ARGS &gt;&gt; /var/log/my-daemon 2&gt;&amp;1
  </code></pre>
  <p>But this does not log anything to the log file. From the man page of <code>start-stop-daemon</code>, it sounds like <code>--no-close</code> would be the right thing to use here. But my system uses <code>start-stop-daemon</code> from Busybox:</p>
  <pre><code>BusyBox v1.32.0 () multi-call binary.
  
  Usage: start-stop-daemon [OPTIONS] [-S|-K] ... [-- ARGS...]
  </code></pre>
  <p>Which does not seem to support <code>-C</code> or <code>--no-close</code>.</p>
  <p>Is there a solution to that, or do I need to change my init system because I won't be able to achieve what I want with Busybox?</p>
  <p>Note: the following seems to work (at least sometimes), but feels wrong (otherwise there would be no need for <code>--background</code>, right?):</p>
  <pre><code>start-stop-daemon -S -x $DAEMON -- $ARGS &gt;&gt; /var/log/my-daemon 2&gt;&amp;1 &amp;
  </code></pre>