How to disable logging and delete the logs?

Asked by Patrick Knight

How can I disable logging on my computer? I'm running Ubuntu on a netbook with a really small disk.

On a related note, is it safe to delete all the logs on my system by executing the following commands:

cd /var/log
sudo rm -rf *

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Steven Danna
Solved:
Last query:
Last reply:
Revision history for this message
Best Steven Danna (ssd7) said :
#1

I'm not sure it is a good idea to delete all the logs, since many of them will be in use and they are, in general good to have around; however, I appreciate not wanting logs wasting space when your hdd space is limited. This is what I would try:

1) Delete Old Log files:

cd /var/log
sudo rm -rf *.[0123456789]*

This will delete all the logs that have been "rotated."

2) Change your log rotation settings. Logs are "rotated" by logrotate. This takes the current log renames it and then creates the new log. This is so that when you actually need the logs, you aren't trying to read through the last 2 years worth of data. You can adjust how long each log is kept by editing /etc/logrotate.conf

Try this:

gksudo gedit /etc/logrotate.conf

In this file you will see this at the very beginning of the file:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

If you change the 4 to a 1 it will only keep a weeks worth of backlogs. There is also an option in there to compress the old log files. Some log files are controlled specifically by files in /etc/logrotate.d/ and there are also many more options. To further customize it you might want to take a look at "man logrotate" (that is, run the command "man logrotate" from the terminal).

Revision history for this message
Patrick Knight (pknight-dev-deactivatedaccount) said :
#2

Thanks Steven Danna, that solved my question.