一、诉求
1、linux服务器开启日志功能,并记录10个月的登录
二、操作
1、进入目录
cd /etc
2、编辑配置
vi logrotate.conf
3、复制配置
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 10
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 10
}
# 登录日志轮转配置
/var/log/auth.log {
create 0600 root utmp
rotate 10
monthly
compress
postrotate
# 重新启动syslogd以 flush 任何缓存的日志数据
kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
# /etc/logrotate.d/syslog
/var/log/syslog {
create 0644 root utmp
rotate 10
monthly
compress
postrotate
kill -HUP `cat /var/run/syslogd.pid 2> /dev/null || echo 1` 2> /dev/null || true
endscript
}
# system-specific logs may be also be configured here.