Articles in this section

Why 'kill HUP' is used in the logrotate configuration?

Detail

As given in the documentation, the logrotate policy defined under /etc/logrotate.d/aerospike has the line "/bin/kill -HUP" for asd process:
 

/var/log/aerospike/aerospike.log {
    daily
    rotate 90
    dateext
    compress
    olddir /var/log/aerospike/
    sharedscripts
    postrotate
        /bin/kill -HUP `pgrep -x asd`
    endscript
}

So, what is the purpose of using this line? Is it necessary to kill the process to configure logrotate?


Answer

Generally, services on the system keep the log files opened while they are running. This means that they do not care if the log files are renamed/moved or deleted they will continue to write to the open file handled.

So "/bin/kill -HUP " is not to kill the process and it is sending SIGHUP signal to asd process to start writing to the new file and close the old file.
SIGHUP is a signal sent on the signal bus to the asd process. The asd process has got a thread listening to sighup signals. On receiving said signal, asd will close and reopen the log file. That’s all that happens.
It will not restart/reload the service and should not affect the working of application.


Applies To Earliest Version

Pre 4.9

Applies To Latest Version

Current Version
Was this article helpful?
0 out of 0 found this helpful