There are several questions about this already but none of them seem to work. I have a production system that is currently down and I need to be able to get the stderr output from the daemon quickly to debug it.
I thought I could just redirect the output from the point it is called (in an init.d script) but it is proving extremely difficult.
start-stop-daemon -d $DDIR -b -m --start --quiet -pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS > /var/log/daemon.log 2>&1 \
|| return 2
This does not work. I tried running a shell script that calls the executable and redirects the output but still the log file remained empty (and I do know that the process is outputting information).
Any help would be extremely appreciated.
If you have start-stop-daemon >= version 1.16.5 you simply call it with --no-close
to be able to redirect the output of the started process.
From man start-stop-daemon
:
-C, --no-close
Do not close any file descriptor when forcing the daemon into the background (since version 1.16.5). Used for debugging purposes to see the process output, or to redirect file descriptors to log the process output. Only relevant when using --background.