I have a process running that writes standard output and standard error to a log file /var/log/dragonturtle.log. Is there anyway to rotate the log file, and have the process continuing to write to the new log file without killing the process?

What happens currently (given the logrotate config below):

  • Process writes to /var/log/dragonturtle.log
  • Logrotate moves /var/log/dragonturtle.log to /var/log/dragonturtle.log.1
  • Process continues to write to /var/log/dragonturtle.log.1

What I would like to happen:

  • Process writes to /var/log/dragonturtle.log
  • Logrotate copies /var/log/dragonturtle.log to /var/log/dragonturtle.log.1
  • Logrotate truncates /var/log/dragonturtle.log
  • Process continues to write to /var/log/dragonturtle.log


/var/log/dragonturtle.log {
    rotate 7
    create 644 dragonturtle dragonturtle

1 Answer 1


The logrotate option that does what you describe is copytruncate. Simply add this option to your existing logrotate config. Here is the excerpt from the logrotate.conf manual:

          Truncate  the  original log file 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 can not 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 truncating it, so  some  log-
          ging  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 was going to suggest something way more complicated involving inode checks and forked processes, but this is WAY simpler.
    – Jeight
    Aug 1, 2014 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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