I have 4 custom systemd services that write to custom logs in /var/log/. I set up a logrotate config file, but it is not writing to the newest log. It is still writing to the old .log.1 file. The new ones are created, just no data.

Here is my logrotate config:

/var/log/dealer*.log {
        rotate 7
        su root root
        /bin/systemctl reload dealer*.service > /dev/null 2>/dev/null || true
        create 0644 root root


The newest log files are empty:

-rw-r--r--  1 root      root               0 Jul 12 11:39 dealerF2f.log
-rw-r--r--  1 root      root               0 Jul 12 11:39 dealerOutbound.log
-rw-r--r--  1 root      root               0 Jul 12 11:39 dealerTimeout.log
-rw-r--r--  1 root      root               0 Jul 12 11:39 dealerWeb.log

It is still writing to the .log.1:

-rw-r--r--  1 root      root             36M Jul 12 12:52 dealerOutbound.log.1
-rw-r--r--  1 root      root            9.2M Jul 12 12:52 dealerF2f.log.1
-rw-r--r--  1 root      root             19M Jul 12 12:52 dealerWeb.log.1
-rw-r--r--  1 root      root            171M Jul 12 12:52 dealerTimeout.log.1

1 Answer 1


Typically I see something like this when a process still has the file open - it will continue to write to the old file until the process is restarted.

My bet is that if you do a restart instead of a reload it will work as expected.

If you cannot restart the process completely look into the copytruncate option instead of the postrotate script.

copytruncate Truncate the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally creating a new one. It can be used when some program cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and trun‐ cating it, so some logging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place.

  • I'm trying to avoid a full restart since my ExecStopPost calls a bash script that sends an email, however, using copytruncate and removing the postrotate section did what I needed. It created the new log, and began writing to it correctly. Thank you very much. Jul 12, 2021 at 20:41
  • copytruncate is a last resort as its design is flawed (because it's the best that can be done given the requirements). The services really should be capable of supporting log file rotation properly. Jul 14, 2021 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.