[LINUX] When the log acquired by rsyslog is not updated after rotation with logrotate

While implementing the function to get the Samba audit log with rsyslog, the log file was not updated after logrotate and it got stuck for a moment, so I will share the solution.

problem

configuration:/etc/rsyslog.d/sample.conf


local5.* /mnt/system/logs/samba/audit.log;RSYSLOG_FileFormat

/etc/logrotate.d/sample


/mnt/system/logs/samba/audit.log {
    create 0644 syslog adm
    ifempty
    dateext
    dateformat .%Y-%m-%d
    maxsize 5G
    missingok
    compress
    monthly
    rotate 12
}

As mentioned above, when logging with rsyslog, the log file is no longer updated after logrotate is executed.

Solution

After logrotate was run, `` `systemctl restart rsyslog``` fixed it. This was solved by automating with ** postrotate ** of logrotate as follows.

/etc/logrotate.d/sample


/mnt/system/logs/samba/audit.log {
    create 0644 syslog adm
    ifempty
    dateext
    dateformat .%Y-%m-%d
    maxsize 5G
    missingok
    compress
    monthly
    rotate 12
+   postrotate
+     /bin/systemctl restart rsyslog
+   endscript
}

It's a little unique to write. Don't forget the endscript.

that's all!

Recommended Posts

When the log acquired by rsyslog is not updated after rotation with logrotate
Notify slack when the switch sales page is updated ~ slack bot development with python ③ ~
What happens to the access log when the website is automatically accessed by selenium-webdriver
Python log is not output with docker-compose up
When the selected object in bpy.context.selected_objects is not returned
Check when the version does not switch with pyenv
Memory is not allocated when ndarray is initialized with numpy.zeros ()
Correspondence when an alert is issued by the workon command after installing virtualenv (MacOS10.10 + Python3.4)
When Pydev is not displayed even after adding Pydev5.2 to Eclipse (2016/8/30)
Multiply the x-axis value by n when plotting with pylab
After deleting the Java process log, the log is no longer output