Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otrenav/92a366c9f405dd9d56ed01d897b9262c to your computer and use it in GitHub Desktop.
Save otrenav/92a366c9f405dd9d56ed01d897b9262c to your computer and use it in GitHub Desktop.
Execute Python and log both stdout and stderr to a file
#
# Print Python script output as well as save it to a file. The `-u`
# switch tells Python to avoid buffering `stderr` and `stdout`
# which is required by `tee` to save the output to the file.
#
python -u main.py | tee output.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment