I am running a python script on startup like this (in
/usr/bin/python3 -u /path/to/script.py > /path/to/output.log 2> /path/to/output.log &
-u option was a failed attempt to fix this problem.) However, my stdout output (such as
print('abc')) does not end up in the log file. After noticing that python errors (such as uncaught exceptions) do end up in the log, I changed all my prints to go to stderr as such:
def eprint(msg): sys.stderr.write(msg) eprint('Hello') devicepath = '/dev/hidraw0' path = Path(devicepath) while not path.is_char_device(): eprint('No device found') time.sleep(1)
But not even those messages make it to output.log. So now my program is running perfectly, but I have no logs at all. Any ideas how to make sure that my output ends up where it's supposed to go?