Greetings to all
I am trying to execute a daemonize python script that is currently running in the foreground. However, I still need to see its output, which it currently resets to standard output.
So, I use the following code snippet that generates a unique file name in / tmp and then assigns sys.stdout to this new file. All subsequent calls to "print" are then redirected to this log file.
import uuid
outfile = open('/tmp/outfile-' + str(uuid.uuid4()), 'w')
outfile.write("Log file for daemon script...\n")
sys.stdout=outfile
.
.
.
The problem I am facing is that when I tail -fcreate a file created in / tmp, I do not see any output. However, as soon as I kill my daemon process, the output will be visible in the / tmp log file because python clears the file data.
tmp , , - .
, , unbeffered IO, .
!
,
Warpcore