Reclamation of file space without terminating a process
To reclaim the blocks allocated to an active file without terminating the process, redirect the output of another command to the file. The data redirection truncates the file and reclaims the blocks of memory.
When the active file is removed from the file system, the blocks allocated to the file remain allocated until the last open reference is removed, either as a result of the process closing the file or because of the termination of the processes that have the file open. If a runaway process is writing to a file and the file is removed, the blocks allocated to the file are not freed until the process terminates.
$ ls -l total 1248 -rwxrwxr-x 1 web staff 1274770 Jul 20 11:19 datafile $ date > datafile $ ls -l total 4 -rwxrwxr-x 1 web staff 29 Jul 20 11:20 datafile
$ ls -l total 8 -rxrwxr-x 1 web staff 1278866 Jul 20 11:21 datefile
The size of the datafile file reflects the append done by the runaway process, but the number of blocks allocated is small. The datafile file now has a hole in it. File holes are regions of the file that do not have disk blocks allocated to them.