Introduction
*Please make sure you discuss this with a qualified system administrator before performing the following actions as they may result in data loss*
Sometimes log files get rather large, and rather than back them up; you may want to truncate the file to a smaller size. Below is how you would do this.
Procedure
The command you would want to run is the truncate command. The simplest way to do this is the following:
truncate -s 100M <file_name>
The command does the following:
Truncates the file to the most recent 100 Megabytes of data (retains the newest data and removes all older data in the file above the 100M in size).
For more information on truncate, please refer to the following documentation for truncate built into your operating system.
man truncate
Also, you may want to truncate your logs regularly; logrotate would be helpful in this case.
Comments
0 comments
Article is closed for comments.