[OpenWrt-Devel] [procd] How to redirect STDOUT/STDERR of a started service ?

Christian Schoenebeck christian.schoenebeck at gmail.com
Mon Dec 15 15:05:30 EST 2014

Am 14.12.2014 um 19:42 schrieb John Crispin:
> On 14/12/2014 19:27, Christian Schoenebeck wrote:
>> Hi, I provided privoxy 3.0.22 package with scripts using procd to
>> run the service. When privoxy runs in foreground it never writes to
>> logfile. So it's required to redirect stdout and/or stderr of this
>> started service to a file. I asked the developers of privoxy how to
>> fix this. I got a tip to create a patch for privoxy to fix this
>> problem but it's not supported.
>> I think there must be a chance to give parameters to procd to
>> redirect STDOUT/STDERR.
>> I tried procd_append_param command '>/var/log/out.log' and 
>> procd_append_param command '2>/var/log/error.log'
>> without and with single and double quotes without success. The
>> service did not start without any errors reported neither from the
>> service nor from procd. If I redirect from the command line
>> everything works fine.
>> What did I wrong ? How to debug whats going on ?
>> Thanks for support Christian 
>> _______________________________________________ openwrt-devel
>> mailing list openwrt-devel at lists.openwrt.org 
>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> Hi,
> that wont work i am afraid. logging to a file is a bit quirky as the
> log wont rotate and eventually fill up /tmp. i will look into this
> during the week and add an option to redirect stdout to the syslog.
> 	John
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Hi John,

the logging problem of services like privoxy or dnsmasq and others exists also without procd.
For this there is logrotate or self written scripts that do the truncate.
My problems during testing was that there was no output from procd, why the process was not started.
Something like "syntax error" or similar, either on console or inside syslog would help.

I think it should be possible to redirect stdout and stderr of a by procd started process to file.
This file could be /dev/null by default (like today), to /dev/stderr or /dev/stdout for console output,
/var/log/file or other files

or simply accept ">...." "2>....." as command line parameter. Then it's possible to 1:1 transfer a working command line to procd_set_param/procd_append_param command ...
or if there are problems with handover ">" via json
procd_set_param stdout /dev/null	(what is the default if nothing given)
procd_set_param stderr /dev/null

What do you think ? I don't know what is possible to code.

More information about the openwrt-devel mailing list