Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 6 down vote accepted

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.
share|improve this answer
I was going to suggest something way more complicated involving inode checks and forked processes, but this is WAY simpler. – Jeight Aug 1 '14 at 22:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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