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