Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/CloudIngenium.com/htdocs/wp-includes/functions.php on line 6114
How to: Erase a log file in Ubuntu – Knowledge eXchange

How to: Erase a log file in Ubuntu

How to: Erase a log file in Ubuntu

Ever had this huge error log, full of nightmares and bad memories? Well, once you’re done fixing the problems then you’re stuck with megs if not gigs worth of bad memories that perhaps you wish to get rid off. Well, in my case one of my errors sent so much information to the log file it was on the gigs arena. This obviously becomes an issue as much of that information is not important to me any more and it can have a performance impact on the system.

Usually I would move the original file to a backup location and create a new one. The issue with this approach is that the permissions or attributes of the original file need to be copied over to the new one… more work basically. So I did some research and it is possible to simply truncate your log file so that all you’re doing is getting rid of the data within and keeping all the attributes and the like untouched.

There are a couple of ways to do this: You can do some fancy output redirection or you could use the truncate command. Either way the result is the same and all it takes is one command line. Here it goes:

Option 1: Redirect output to the file to clear it:

If you simply redirect null output to the file, basically you’re wiping it clean. Simply do the following:

>error.log

Option 2: Use the truncate command:

For those who feel more at home with a traditional command instead of ninja magic:

truncate -s0 error.log

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.