I am using logrotated to rotate gunicorn access logs. This is my logrotated configuration
/opt/api/log/access.log {
daily
rotate 10
missingok
notifempty
compress
sharedscripts
postrotate
killall -s USR1 gunicorn
endscript
}
The logs get rotated correctly, compressed, and a new access.log gets created. However, gunicorn does not release a 'pointer' to the old log file, so the rotation doesn't actually free up disk space.
I can still see entries for it using lsof
If I do an initctl restart api
, gunicorn will restart and the disk space is finally freed up.
How can I free up the disk space in a cleaner way than restarting the service?