You have to be careful with this though. File::Copy's move() will attempt to rename the file and, failing that (for example if the file is being moved across filesystem boundaries) will copy the file over and unlink the original. As sauoq quite rightly points out, this procedure runs the risk of losing log messages which are written in between the copy and the unlink.
If you are trying to move a file to a different filesystem you should first rename it to a temporary location on the same filesystem as the original, then make sure that no more messages can be written to the renamed file (for example, by HUPing the daemon that logs to the file), then move the temporary file to it's final destination. You can use File::Copy for this last step if you want.
|