server,
[root@server logrotate.d]# cat /etc/logrotate.conf
# system-specific logs may be also be configured here.
/var/log/user.log {
missingok
notifempty
maxsize 20 M
create 0666 root
mqm
rotate 8
}
//above is not working that need to command if they present
# cat /etc/rsyslog.conf
#IIB SYSLOG
user.info /var/log/user.log
#systemctl status rsyslog.service
//is running
#cd /etc/logrotate.d
[root@server logrotate.d]# ls
bootlog httpd kadmind
libvirtd named piranha
samba subscription-manager tomcat
wpa_supplicant
cups
iscsiuiolog krb5kdc libvirtd.qemu
numad psacct sssd
syslog up2date yum
[root@server logrotate.d]# ls /etc/rsyslog.d/
listen.conf
[root@server logrotate.d]# cat /etc/rsyslog.d/listen.conf
$SystemLogSocketName /run/systemd/journal/syslog
samples for creating new log (user.log) to include in
logrotate
/bin/systemctl restart rsyslog.service > /dev/null
2>/dev/null || true
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/bin/systemctl
reload httpd.service > /dev/null 2>/dev/null || true
endscript
}
/var/log/sssd/*.log {
weekly
missingok
notifempty
sharedscripts
rotate 2
compress
delaycompress
postrotate
/bin/kill -HUP
`cat /var/run/sssd.pid
2>/dev/null` 2> /dev/null
|| true
endscript
}
//created
[root@server logrotate.d]# pwd
/etc/logrotate.d
[root@server logrotate.d]# vi user
/var/log/user.log {
weekly
missingok
notifempty
sharedscripts
create 0666 root
mqm
rotate 2
compress
postrotate
/bin/systemctl
restart rsyslog.service > /dev/null 2>/dev/null || true
endscript
}
---------------------------
logrotate -s /var/log/logstatus /etc/logrotate.conf
/var/log/user.log {
create 0666 root
mqm
weekly
missingok
rotate 8
compress
notifempty
sharedscripts
dateext
postrotate
/bin/kill -HUP
`cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
//final compossed
/var/log/user.log {
weekly
missingok
rotate 8
compress
notifempty
sharedscripts
dateext
postrotate
/bin/kill -HUP
`cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
//how to check if our log rotate is working fine
# logrotate -f /etc/logrotate.conf
//it validate the whatever the file prenstn in
/etc/logroate.d
0 Comments