Linux – how to trim or clean log file
Below You’ll find my method for trimming or cleaning logs file.
For example if You want trim log – leave the last 10 lines, use:
echo "$(tail -n 10 error_log)" > error_log
For cleaning log files use one of below commands:
1. truncate -s 0 filename
2. cat /dev/null > file.log
3. echo "" > error_log
4.
touch newfile
mv newfile logfile