What is the difference between `copytruncate` and `create` + postrotate signal?
IntermediateProductionLogs, Limits & High-Traffic Tuning
Answer
With create, logrotate renames the file and creates a new one; the app keeps writing to the old (renamed) inode until told to reopen (SIGHUP/USR1, nginx -s reopen). With copytruncate, logrotate copies the file then truncates the original in place, so the app needs no signal, but lines written between copy and truncate are lost, and apps not using O_APPEND leave a sparse file with a hole. Prefer reopen signals; use copytruncate only for apps that cannot reopen logs.
More on Logs, Limits & High-Traffic Tuning
How does log management work on a modern Linux server?BeginnerWhy centralize logs instead of reading them on each server?BeginnerWrite a logrotate config for an application log.BeginnerLogs rotated but disk usage did not drop. Why?IntermediateHow often does logrotate run, and why does `maxsize` sometimes not trigger in time?IntermediateHow do you limit journald disk usage?Intermediate