Tuesday, November 15, 2011

How to rotate sudo log?

■ Requirement : Rotate sudo log messages
■ OS Environment : Linux, RHEL, Centos
■ Assumption : 

  •    sudo log file = /var/log/sudolog
  •    log retention = 90 days

■ Implementation Steps :

1. Edit /etc/sudoers and add following lines :

Defaults !syslog
Defaults logfile = /var/log/sudolog

2. Rotating this log file :

edit /etc/logrotate.d/sudolog and put following :

/var/log/sudolog {
rotate 90
size 5M
postrotate
/usr/bin/killall -HUP syslogd
endscript
}

4. Restart syslogd service :

$service syslogd restart

No comments:

Post a Comment