1

It is a bit weird that in my /var/log dir, many files such as syslog, auth.log all seem to have older log files (rotated by [0-9], some like dpkg.log even rotates to 12 now), but the important wtmp log file only has a wtmp.1 rotation, which stores pretty recent log (I have been using the laptop for several years, so in normal case it should have more wtmp logs).

Is it because of some system setting that prevents my laptop from storing more wtmp logs? (I do not recall that I changed the default setting for this.)

Thank you.

2

You just need to edit the /etc/logrotate.conf file:

sudo gedit /etc/logrotate.conf

Mine by default looks like this:

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

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}

# system-specific logs may be configured here

All you have to do is changing:

/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1  <------ change this value to 12 to keep log files for 12 months
}

by

/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 12
}

to keep log files for 12 months.

3
  • it appears that the wtmp and also the rotated wtmp.n are not ASCII file and can only be read by the "last" command, so if they are compressed, one has to first uncompress them and then use "last -f ..." to read. The other compressed log files can be easily read via emacs since they are ASCII text files. Is there a way to set "compress" for all other logs files except the wtmp? (I assume if #compress is uncommented, all log files will be compressed, including the wtmp.) Thanks. – water stone Apr 7 '14 at 10:45
  • Could you please create a new question to cover the compression of log files? Thanks – Sylvain Pineau Apr 7 '14 at 11:01
  • just did, see here askubuntu.com/questions/444609/… – water stone Apr 7 '14 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.