Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76836 > unrolled thread

Re: Halfway point between interactive and daemon?

Started byCameron Simpson <cs@zip.com.au>
First post2014-08-23 12:09 +1000
Last post2014-08-23 12:09 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Halfway point between interactive and daemon? Cameron Simpson <cs@zip.com.au> - 2014-08-23 12:09 +1000

#76836 — Re: Halfway point between interactive and daemon?

FromCameron Simpson <cs@zip.com.au>
Date2014-08-23 12:09 +1000
SubjectRe: Halfway point between interactive and daemon?
Message-ID<mailman.13321.1408759809.18130.python-list@python.org>
On 22Aug2014 12:27, Travis Griggs <travisgriggs@gmail.com> wrote:
>I’m curious if there’s a technique one could use to get half way there.  
>Basically, with minimal modifications, I’d like to get it running at startup.  
>So I can put a line like this in rc.local
>
>nohup python3 myMain.py 2>&1 > /var/log/mylog.log &

Just to this. You have your redirections backwards. They are applied left to 
right. So, first "2>&1": sending stderr to where stdout currently goes 
(probably the system console if this runs from rc.local). Then, "> 
/var/log/mylog.log": sending current stdout to the log file. Importantly, _not_ 
attaching stderr to the log file.

You want to write this:

   command >log 2>&1

As others have remarked, you do not need to daemonise a process started from 
rc.local.

And as others have remarked, if you want it to start/stop under external 
conrol, or restart after a program abort etc, you may be better adding it as to 
the configuration of something like systemd or init.

That said, I start a bunch of things in rc.local. It is quick and easy, and 
also handy for stuff that shouldn't be restarted automatically if it dies.

>Then I can “check” on it when I need to with a tail -f /var/log/mylog.log. But 
>then I have the problem of managing the log size. And also I either have to 
>wait for stdout to flush, or insert sys.stdout.flush() after any of my 
>print()’s.

Log messages should be going to stderr anyway, which by default is unbuffered.

Cheers,
Cameron Simpson <cs@zip.com.au>

You can't have everything...  where would you put it?
         - Charles Robinson, cr0100@medtronic.com

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web