When working with large log files, it can be difficult to open or analyze them. In such cases, you may need to clear the content of existing log files to make space for fresh log data.
There are several safe and effective ways to truncate or empty log files in Linux.
Methods to Clear Log Files
- : > application.log – Redirects nothing into the file, effectively clearing it.
- cat /dev/null > application.log – Writes an empty stream into the file.
- truncate -s 0 application.log – Sets the file size to zero without deleting it.
Clear Multiple Log Files
To empty all log files ending with .log inside a directory, you can use:
sudo truncate -s 0 /<directory-path>/**/*.log
Tip: Always back up important logs before clearing them, as this process permanently removes the file content.
Search
Categories
Recent Posts
Hyundai Exter 2026: Price, Features, Mileage & Safety | 5-Star NCAP
Maruti Suzuki Swift 2026: Price, Features, Mileage & Safety Rating | 4-Star NCAP
Maruti Brezza 2026: Price, Features, Mileage & Safety Rating
Tata Punch 2026: Price, Features, Mileage & Safety Rating | 5-Star NCAP
Fuel Cost Calculator India 2026 – Compare Petrol, Diesel, CNG & EV Running Costs
Recent Tags