python script output won't be directed to file

Zeinab Abbasimazar

I have a python script. It has a SimpleLogger with sys.stdout as output_stream.

logger = SimpleLogger(level=LogLevel.DEBUG)

When I run it in console, I get the logs properly, but whenever I redirect the output to a file, nothing is found in the target.

I tried multiple ways:

  1. python server.py > /tmp/x.log 2>&1
  2. python server.py > /tmp/x.log

In both cases, the /tmp/x.log is empty.

I also tried nohup python server.py, but nothing has been written in nohup.out.

meuh

This is probably just due to buffering. You will only see something in the file when enough output has been accumulated. You can try using python -u to ask for unbuffered output, or set environment variable PYTHONUNBUFFERED= to any non-empty string, as documented in the Python command line documentation, or add a .flush() call after each .debug() or similar call.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python won't write to file

From Dev

Script won't write the time to file

From Dev

Python DictWriter: why won't python quickly return my output file? Using Counter, csv and group-by

From Dev

Python DictWriter: why won't python quickly return my output file? Using Counter, csv and group-by

From Dev

python script won't divide floats

From Dev

Linux Crontab executes PHP script but this Script won't delete file

From Dev

String is not being directed to Output file (C++)

From Dev

gcc error output not getting directed to file

From Dev

Python won't overwrite 777 file

From Dev

Why won't this python code open the file?

From Dev

sink() won't print output to text file in rmarkdown

From Dev

Running a perl script in python and storing the output in a file

From Dev

Need to append output from the python script to the file

From Dev

Output of print to file Inside script | Python

From Dev

crontab automated python script won't upload to dropbox

From Dev

Python script won't run from the context menu

From Dev

Python webserver script won't submit to sqlite3 database

From Dev

Palindrome won't output correcly

From Dev

PigLatin won't output correctly

From Dev

Javascript won't output to HTML

From Dev

python 3 directed graph with labels from file

From Dev

PBSPro qsub output error file directed to path with jobid in name

From Dev

jQuery script won't run

From Dev

Autologin script won't work

From Dev

jQuery script won't run

From Dev

Crontab won't execute script

From Dev

Bash script won't run

From Dev

Code won't write to CSV file Python3, why?

From Dev

Python ElementTree won't update new file after parsing

Related Related

HotTag

Archive