Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Ubuntu 10.04, I have a long Python program that prints a bunch of output; I run this under "nohup". However, it waits until the end to put all the text in nohup.out. When I run similar programs under FreeBSD, each line gets sent to nohup.out. Is there a Ubuntu setting I can set to get the output faster?

share|improve this question
up vote 5 down vote accepted

Yeh, this is got to do with the way stdout is buffered by default on Linux. You need to explicitly run setbuf() in the code to override this behavior.

My suggestion is to avoid nohup, if you're using the bash shell, it allows you to disassociate the command from your shell

$ ( my_cmd > ~/output.log 2>&1 & ) 

You can also use disown for a similar effect on a currently running job.

share|improve this answer
Why would you recommend avoiding nohup? – Warner Sep 13 '10 at 14:36
I think because putting setbuf() in every Python script that might be nohup'd is silly. – Paul Hoffman Sep 15 '10 at 17:22

Since your program is python, you can run it with python -u. Alternatively you might find the unbuffer program useful.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.