I'm in the following situation: I'm working on a FreeBSD 8.0 machine and I have a custom init script for a service (let's call it "myservice").
Its path is
and it contains the following text
run_rc_command "$1" 2> /var/log/myservice.log
As you can see, in the last line I added "2> /var/log/myservice.log" so I can have a (kind of) log file (this because the service is a stupid one and doesn't implement a logging mechanism but simply writes everything on the console).
This solution works, and I have the "/var/log/myservice.log" log file with all the stderr messages I need.
Now, my problem is:
1) how can I log stdout too? If I use "&>" instead of "2>", the shell parses it as "& >" (note the space)
2) even if the text printed on the console by the service is *plain text*, my log file *always* begins with a lot of 0x00 characters (the number of those chars, always on the stop of file, seems to be increasing as the log file gets bigger). Infact, if I use the "file" command on the log file, I get "data" instead of "ASCII text". Very odd!
My question is: how can I log both stdout and stderr of that service to a file in the most simple way?