PDA

View Full Version : close open files before remove



xramm
3rd September 2007, 02:27 PM
Hi
I have a script to remove log files when it reaches %70 usage in order to descending order of dates. But sometimes it happens to remove open - being processes files , so makes them unlinked from the directors and results them disappeared.
How can I solve this problem , simple scenario I thought that first close file and then remove. But is there any unix utility to do this??

For example: I looked for file-close option in "rm" command, but I could not find. ?

Any advise ?

jim
3rd September 2007, 03:02 PM
is this run via cron? if so change the time the job runs so it runs when no logs are being written to

xramm
3rd September 2007, 03:24 PM
yes runs via cron, but since files are being written continuously in 12 hours interval I think, I don t seem to have any chance not to close files became bigger and older.
thanks.
is it complex process to close an open file?