Why is kill -HUP used in logrotate in RHEL? Is it necessary in all cases?
9
votes
2
answers
19048
views
I see for syslog logging, kill -HUP is used.
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
sharedscripts
postrotate
/bin/kill -HUP
cat /var/run/syslogd.pid 2> /dev/null
2> /dev/null || true
endscript
}
I understood that -HUP is used because daemons like syslog, when they catch the SIGHUP, will try to restart itself and thus all the openfiles will be refreshed.
I do not understand why they need to be refreshed.
If syslog does only appending new log to the log files, the open files would be in write mode. If that is the case, when the log switching happens and at some point when the old log file entry in the filesystem is removed, won't it be creating a new file automatically when it needs to append a new log line (as afterall syslog service is running as root)?
I think the difference is more in the understanding of w and u modes. I am unable to come to a quick conclusion on it.
Also, why use only kill -HUP, why not restarting the service. Will there be any difference?
Asked by GP92
(915 rep)
Apr 25, 2018, 02:43 PM
Last activity: Apr 25, 2018, 03:16 PM
Last activity: Apr 25, 2018, 03:16 PM