How to Force a File Handle to Point to a New File?

My developer delivered a program which creates a time-stamped logfile and the only way the logfile rolls is with the size parameter in the log4j file. The user wants to be able to roll the logs manually at the end of the day or shift or when a particular event occurs. I tried to manipulate the /proc/<pid>/fd/<fd> link to point to a fresh logfile, but the system won't allow it. Are there any other tricks or ideas (short of killing the process and restarting) that will allow me to terminate writing to the current file and start writing to a new file. Thanks in advance

You can't force a running program to flush its internal buffers, close a file, and open a new file unless the code for that program was written with code to make that happen. Some system monitoring programs are designed to rotate log files when they receive a certain signal. The documentation for your system monitoring program should describe any such mechanism it provides. If your developer didn't provide such a mechanism and you need it to satisfy your users, file an enhancement request.

1 Like