Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Aug 2014 09:44:19 +0200
From:      Peter Ulrich Kruppa <ulrich@pukruppa.de>
To:        freebsd-questions@freebsd.org
Subject:   [SOLVED] Re: sh stdout/stderr redirection problem
Message-ID:  <53F05D53.3030001@pukruppa.de>
In-Reply-To: <20140816165446.db6aefc6.freebsd@edvax.de>
References:  <53EF6979.2080708@pukruppa.de> <20140816165446.db6aefc6.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On 16.08.2014 16:54, Polytropon wrote:
> On Sat, 16 Aug 2014 16:23:53 +0200, Peter Ulrich Kruppa wrote:
>> Hi,
>>
>> I have got a python3.4 script which I can start from an rc.d script as a
>> daemon this way:
>> 	
>>   daemon -p /var/run/my.pid /path/to/python3.4 /path/to/myscript.py
>>
>>
>> /path/to/python3.4 /path/to/myscript.py produces interesting messages on
>> stdout and stderr, so I would like to collect them in /var/log/my.log .
>> I have tried all kinds of combinations of >>'s and 2>&1's but either I
>> catch daemon's output which is nothing or the script won't start anymore.
>>
>> Any ideas? - Thanks for your help

After some playing around:

> Idea:
> 
> 	# ( daemon -p /var/run/my.pid /path/to/python3.4 /path/to/myscript.py ) > /tmp/myscript.log 2>&1
This doesn't work: it produces an empty logfile ...

> You can use ( ... ) to "summarize" subshell outputs, but in
> your case using _script_ is probably the easiest method. It
> will capture all output written to the terminal (stdout and
> stderr). See "man script" for details.
That's not "elegant" but it works for me. I have to use a long command

daemon -f -p /var/run/my.pid script -a /var/log/my.log \
/path/to/python3.4 /path/to/myscript.py

Thanks for your input!

Greetings

Peter



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53F05D53.3030001>