/var/log/syslog not rotating

The logs at /var/log are not getting rotated with the result that the files are bloating in size and filling up the server.

The command

 sudo logrotate -f /etc/logrotate.d/rsyslog 

shows the error

  error: skipping "/var/log/syslog" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

According to the post at askubuntu.com,

Determine the su user/group to use from the global logrotate config file

 grep 'su ' "/etc/logrotate.conf"

Edit rsyslog logrotate config

 nano "/etc/logrotate.d/rsyslog"

Prepend the su line (from step 1) to the top of the file:

 su root syslog

Test for errors

 logrotate --debug --force /etc/logrotate.d/rsyslog 2>&1 | grep -i cron

I also changed the parameters in “/etc/logrotate.conf” to provide for daily rotation.

# see "man logrotate" for details

# global options do not affect preceding include directives

# rotate log files weekly
# weekly
daily
# use the adm group by default, since this is the owning group
# of /var/log/.
su root adm

# keep 4 weeks worth of backlogs
rotate 1

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

# use date as a suffix of the rotated file
#dateext

# uncomment this if you want your log files compressed
compress

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

# system-specific logs may also be configured here.
 nano /etc/logrotate.d/rsyslog 

Leave a Reply

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