Bruno Polaco asked:
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
Change the file descriptor of the application process to point back again to
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?
Most such applications respond to a signal, such as
SIGHUP, and will close and reopen their log files on receipt of the signal. Check your application’s documentation for the correct signal to send.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.