From owner-freebsd-questions@FreeBSD.ORG Sat Aug 16 17:32:03 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0D1D2590 for ; Sat, 16 Aug 2014 17:32:03 +0000 (UTC) Received: from www81.your-server.de (www81.your-server.de [213.133.104.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0B7F2425 for ; Sat, 16 Aug 2014 17:32:02 +0000 (UTC) Received: from [188.96.38.167] (helo=michael-think) by www81.your-server.de with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80.1) (envelope-from ) id 1XIhb1-0004Dn-U3; Sat, 16 Aug 2014 19:16:52 +0200 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: freebsd-questions@freebsd.org, "Peter Ulrich Kruppa" Subject: Re: sh stdout/stderr redirection problem References: <53EF6979.2080708@pukruppa.de> Date: Sat, 16 Aug 2014 19:16:43 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Michael Ross" Message-ID: In-Reply-To: <53EF6979.2080708@pukruppa.de> User-Agent: Opera Mail/1.0 (Win32) X-Authenticated-Sender: gmx@ross.cx X-Virus-Scanned: Clear (ClamAV 0.98.4/19286/Sat Aug 16 06:42:47 2014) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Aug 2014 17:32:03 -0000 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 > > Peter You could do the redirection in your python script: http://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python Basically, import sys f=open('logfile','w') def redirect(msg): f.write(msg) sys.stdout=redirect sys.stderr=redirect Michael > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"