Skip to main content

From the Unix Power Tools, 3rd Edition: Instead of Removing a File, Empty It section:

If an active process has the file open (not uncommon for log files), removing the file and creating a new one will not affect the logging program; those messages will just keep going to the file that’s no longer linked. Emptying the file doesn’t break the association, and so it clears the file without affecting the logging program.

(emphasis mine)

I don't quite getunderstand why a log program will continue to log to a deletedeleted file?. Is it because the file descriptor entry not getting removed from the process table?

From the Unix Power Tools, 3rd Edition: Instead of Removing a File, Empty It section:

If an active process has the file open (not uncommon for log files), removing the file and creating a new one will not affect the logging program; those messages will just keep going to the file that’s no longer linked. Emptying the file doesn’t break the association, and so it clears the file without affecting the logging program.

(emphasis mine)

I don't quite get why a log program will continue to log to a delete file? Is it because the file descriptor entry not getting removed from the process table?

From the Unix Power Tools, 3rd Edition: Instead of Removing a File, Empty It section:

If an active process has the file open (not uncommon for log files), removing the file and creating a new one will not affect the logging program; those messages will just keep going to the file that’s no longer linked. Emptying the file doesn’t break the association, and so it clears the file without affecting the logging program.

(emphasis mine)

I don't understand why a program will continue to log to a deleted file. Is it because the file descriptor entry not getting removed from the process table?

edited tags
Link
Geek
  • 6.9k
  • 15
  • 51
  • 73
Source Link
Geek
  • 6.9k
  • 15
  • 51
  • 73

How can a log program continue to log to a deleted file?

From the Unix Power Tools, 3rd Edition: Instead of Removing a File, Empty It section:

If an active process has the file open (not uncommon for log files), removing the file and creating a new one will not affect the logging program; those messages will just keep going to the file that’s no longer linked. Emptying the file doesn’t break the association, and so it clears the file without affecting the logging program.

(emphasis mine)

I don't quite get why a log program will continue to log to a delete file? Is it because the file descriptor entry not getting removed from the process table?