I have an linux application that continually writes logging information into a log file, eg. /var/log/application.log
. As the application does not rotate the file automatically, this log file can reach a size of gigabytes in some weeks, so I want to be able to rotate this file properly
My main concern here is that to rotate a file that is opened by the application at all times, I will probably need to:
Move the file to its rotated form
/var/log/application.log -> /var/log/application.log.2013-01-28
Create an empty
/var/log/application.log
. Obs: At this point the application process is still writing to/var/log/application.log.2013-01-28
Change the file descriptor of the application process to point back again to
/var/log/application.log
So, am I right? If so, how can i do this? (mainly the changing the file descriptor part)
If i am not, what is the correct way and how to do it?