logrotate: a separate file for a small custom service

A small template for an app that writes plain files under /var/log.

copytruncate is not perfect, but it is sometimes necessary for simple apps that cannot reopen logs on signal. If the app can reopen logs, prefer postrotate.

sudoedit /etc/logrotate.d/myapp
# /var/log/myapp/*.log {
#   daily
#   rotate 14
#   compress
#   missingok
#   notifempty
#   copytruncate
# }
sudo logrotate -d /etc/logrotate.d/myapp

Verify the result

Run with -d first. It is a dry run and reports syntax errors without rotating anything.