You Asked: How Do You Trim a Log File in Linux?
Contents the Safest Method to Empty a Log File in Linux Is by Using the Truncate Command. Truncate Command Is Used to Shrink or Extend the Size of Each File to...
Contents
The safest method to empty a log file in Linux is by using the truncate command. Truncate command is used to shrink or extend the size of each FILE to the specified size. Where -s is used to set or adjust the file size by SIZE bytes.
How do I truncate a log file in Linux?
You can simply truncate a log file using > filename syntax. For example if log file name is /var/log/foo, try > /var/log/foo as root user.
How do I edit a log file in Linux?
To modify the configuration files:
- Log on to the Linux machine as “root” with a SSH client such as PuTTy.
- Back up the configuration file you would like to edit in /var/tmp with the command “cp”. For example: # cp /etc/iscan/intscan.ini /var/tmp.
- Edit the file with vim: Open the file in vim with the command “vim”.