We will use the size 0 (zero) to empty the file. It is used to shrink the size of a file to a desired size. Truncate is a command line utility that can be found in most Linux distros. We will only deal with the case where you want to completely empty the file or zero it out and not the case where you might want to remove parts of the file or truncate files by certain number of lines or byte size. The truncation process however reduces the need for the two different steps and also will preserve the inode of the file. You can always delete the file and recreate the file, which might work in most cases. This process is also referred to as “ zero out a file” or to “ empty a file“. This allows the file to re-used or be continually used by other programs while keeping the overall size in check. It does not however remove the file itself, but it leaves it on the disk as a zero byte file. The truncation process basically removes all the contents of the file. This is not just relegated to log files, but could also happen to output files or any other file as well. This is especially true about log files, which often contains a large amount of outdated data. Sometimes, you want to start over by emptying the file especially if you are trying to minimize disk space. Quite often it is possible to end up with large files, especially large log files on your system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |