When I want to free up disk space used in a log file instead of
removing the file, which creates the above situation of large files
that no longer have a directory entry, instead of removing the file I
truncate it.
$ :> somelargefile
By truncating the file it is immediately reduced and the disk blocks
freed. The file isn't removed and therefore won't be lost from the
filesystem where du can't find it anymore. Any daemon that is still
writing to the file will still keep its file handle to it and will
continue to write to the file.
Bob