NAME

File::Rotate::Simple - no-frills file rotation

SYNOPSIS

use File::Rotate::Simple qw/ rotate_files /;

rotate_files(
    file => '/foo/bar/backup.tar.gz',
    age  => 7,
    max  => 30,
);

rotate_files(
    files => [ qw{ /var/log/foo.log /var/log/bar.log } ],
    max   => 7,
);

or the legacy interface:

File::Rotate::Simple->rotate(
    file => '/foo/bar/backup.tar.gz',
    age  => 7,
    max  => 30,
);

or the object-oriented interface:

my $r = File::Rotate::Simple->new(
    file => '/foo/bar/backup.tar.gz',
    age  => 7,
    max  => 30,
);

$r->rotate;

DESCRIPTION

This module implements simple file rotation.

Files are renamed to have a numeric suffix, e.g. backup.tar.gz is renamed to backup.tar.gz.1. Existing file numbers are incremented.

If "max" is specified, then any files with a larger numeric suffix are deleted.

If "age" is specified, then any files older than that number of days are deleted.

Note that files with the extension 0 are ignored.

RECENT CHANGES

Changes for version v0.4.2 (2026-08-08)

See the Changes file for more details.

REQUIREMENTS

This module lists the following modules as runtime dependencies:

See the cpanfile file for the full list of prerequisites.

INSTALLATION

The latest version of this module (along with any dependencies) can be installed from CPAN with the cpan tool that is included with Perl:

cpan File::Rotate::Simple

You can also extract the distribution archive and install this module (along with any dependencies):

cpan .

You can also install this module manually using the following commands:

perl Makefile.PL
make
make test
make install

If you are working with the source repository, then it may not have a Makefile.PL file. But you can use the Dist::Zilla tool in anger to build and install this module:

dzil build
dzil test
dzil install --install-command="cpan ."

For more information, see How to install CPAN modules.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/robrwo/File-Rotate-Simple/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SOURCE

The development version is on github at https://github.com/robrwo/File-Rotate-Simple and may be cloned from https://github.com/robrwo/File-Rotate-Simple.git

AUTHOR

Robert Rothenberg perl@rhizomnic.com

CONTRIBUTOR

Mohammad S Anwar mohammad.anwar@yahoo.com

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015-2026 by Robert Rothenberg.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

SEE ALSO

The following modules have similar functionality:

There are also several logging modules that support log rotation.