Logrotate issue with NGINX log files

the logrotate config file “hestia” seems cannot properly rotate nginx-access.log and nginx-error.log

After it makes the new log files, the log still write to old one.

Tried to add this to the bottom of the file but still doesnt work

sharedscripts
    postrotate
        [ -f /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
        endscript
1 Like

Turned out is “Hestia” service locking these 2 files so reload NGINX service wont let write into the new log file. Need to reload Hestia service instead.

sharedscripts
postrotate
	service hestia reload
endscript

You must use the right pid for the Nginx used by Hestia:

/var/log/hestia/*.log {
    rotate 12
    monthly
    missingok
    notifempty
    create 0600 root root
    postrotate
        [ -f /run/hestia-nginx.pid ] && kill -USR1 "$(cat /run/hestia-nginx.pid)"
    endscript
}

I’ll create a PR to fix it.

This is the PR:

Tried but not working, this will create a new log file owned by hestiaweb, but unable to write log inside.

as long as the files owned by hestiaweb, permission denied

2025/11/11 23:17:20 [emerg] 770942#0: open() "/var/log/hestia/nginx-error.log" failed (13: Permission denied)
2025/11/11 23:17:20 [emerg] 770942#0: open() "/var/log/hestia/nginx-access.log" failed (13: Permission denied)
2025/11/11 23:19:09 [emerg] 770942#0: open() "/var/log/hestia/nginx-error.log" failed (13: Permission denied)
2025/11/11 23:19:09 [emerg] 770942#0: open() "/var/log/hestia/nginx-access.log" failed (13: Permission denied)

Try this:

/var/log/hestia/*.log {
    rotate 12
    monthly
    missingok
    notifempty
    create 0600 root root
    sharedscripts
    postrotate
        systemctl restart hestia.service >/dev/null 2>&1 || true
    endscript
}
1 Like

Yes this will work as service hestia reload

But may I know if I must put in || true afterward?

I prefer to use systemctl in case Hestia drops support to the init script. Also, in this case reload and restart do exactly the same (a restart of the service).

It allows to logrotate to continue in case the restart fails.

Thanks. Seems like if I didn’t put ||True

Yesterday night, the hestia service dead and need restart manually this morning

1 Like

may also need to revise your PR? Thanks

1 Like

The PR also has the last change.

1 Like