L
L
lcd12322016-04-09 01:19:14
Python
lcd1232, 2016-04-09 01:19:14

Is it possible to delete the logging log file?

If I have a script running, can I create a cronjob with deleting the log file? Will it be safe or will python throw an error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nirvimel, 2016-04-09
@lcd1232

OS dependent. On Linux, a deleted file opened for writing in another process is not physically deleted, but only ceases to be visible, but continues to be written through the open descriptor (and even read! if the "r" flag is present). On Windows, everything depends on the exclusive lock when opening for writing: if it is present, the deletion will be refused, if it is absent, the deletion will be successful, the descriptor opened for writing will become invalid and all subsequent operations on it will fail (throw an exception).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question