There's a way to do this?

  • Can you tell us why you want to do this? Maybe there's other options...
    – chmeee
    Aug 5, 2009 at 7:01
  • In my case it would be nice to download big old logs to external storage and keep new ones on the server. So I need a simple log splitter.
    – sekrett
    Feb 8, 2016 at 12:43
  • 2
    My use case for this configuration is: I want to keep my log forever, as I may need it for auditing purposes, BUT I want my files to be rotated so that the current log doesn't grow too big and the rotated ones can be compressed - otherwise, backup of the logs to an external server are too difficult, and inspecting the files also gets too slow. May 2, 2016 at 11:20

3 Answers 3


In your logrotate.conf (or the equivilent logrotate.d file), change the line that says "

rotate 10

(your number may be different) to a bigger number. That will tell it to keep that many days of logs. You can make it 36500, which would last you 100 years.

  • 8
    When I did this on a raspberry pi (raspian), it made it freeze every night. Once I cought running processes and open files using the serial console and found out that it tries to rename 100000 of nonexisting files. So beware of it. Unfortunately I don't have more detailed information
    – Christian
    Aug 29, 2016 at 8:51
  • @Christian best not using auto-increment counters as file name extension, but a date extension. That way the rotated files won't get touched again. Dec 17, 2020 at 12:36

I've been looking for this in order to make rotation of my database backups daily, weekly and monthly; so I rotate the file daily but keep the file to do the weekly rotation, and same for the yearly rotation.

Use the copy option. From the manual:


copy Make a copy of the log file, but don’t change the original at all. This option can be used, for instance, to make a snapshot of the current log file, or when some other utility needs to truncate or parse the file. When this option is used, the create option will have no effect, as the old log file stays in place.

  • This is the same as the comment below (serverfault.com/a/50186/275485), and does not provide a correct answer; copy does not mean your old files that were rotated are not deleted.. May 2, 2016 at 11:18

Setting aside the point that rotation involves deletion... ;-)

It looks like you can simply add the word 'copy' to the appropriate file (likely in /etc/logrotate.d). For example, an apache2 logrotate script would look like this:

/var/log/apache2/*.log {
    rotate 52
        if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
            /etc/init.d/apache2 reload > /dev/null

Try that, and see if it does what you want.

  • 2
    Assuming that he wants the files to be "rotated" but just never deleting the old files, this won't do it. Adding "copy" to the config stanza means the original file will continue to grow forever but eventually the older copies of the file will be deleted. As I understand it, "copy" is primarily useful when you expect some other process to truncate/delete the original.
    – Insyte
    Aug 5, 2009 at 7:14
  • Exactly, which is what I thought he was asking for. He specifically asked for a way to "not delete my log files", not a way to "not delete old archives of my log files". Guess I should be more wary of questions that involve just a subject and no body ;-) Aug 6, 2009 at 4:02
  • 2
    The phrase "after rotation" provides a clue. Aug 15, 2009 at 0:06
  • 4
    "Setting aside the point that rotation involves deletion..." Not necessarily. Rotation can involve just compressing the old logs and keeping them, which is what it seems the question asks for.
    – reflexiv
    Jan 23, 2013 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .