The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

file_cleaner_by_du - Removes files based on disk space usage till it drops below the specified amount.

SYNOPSIS

file_cleaner_by_du -p <path> -d <du> [-m <min_files>] [--pretty] [--dry_run] [-q] [-w <file>] [--pid] [--pid_name <name>] [--pid_dir <dir>]

file_cleaner_by_du --version

file_cleaner_by_du --help

DESCRIPTION

This works via doing the following.

1: Check if disk usage is above the specified threshold. If not it ends here.

2: Search for files under the specified path.

3: If the number of found files is less than the number of files to keep regardless of disk size it ends here. So if min_files is set to 32 and there are only 3 files, then it would just return.

4: Get the stats for all the found files.

5: If min_files is specified, remove that many of the files from the list, starting with the newest.

6: Removes the oldest file.

7: Check disk usage again and if it is less it ends here.

8: Go back to 6.

The results are then printed as JSON. To find information on the keys, please see App::FileCleanerByDiskUage.

If there were no errors, it will exit zero.

FLAGS

-d <du>

Target disk usage.

-p <path>

The path to operate on.

This may be specified more than once. Only the first is used for getting usage, so it shoudld not cross partitions.

Paths that are on different mount points run the risk of removing to much as it is never checking the proper partition.

--dry_run

Do not actually delete anything. Instead just check if what it would delete is writable by the current user.

-i <regex>

Optional ignore regex.

-i <min files>

Optional minimum number of files to keep regardless of disk usage.

--pretty

Pretty print the results.

--version

Print version.

--help

Print help,

--pid

Use a PID file.

--pid_name <pid name>

Append this to the the name of the pid file created. If specified with a value of 'foo' then the file would be 'file_cleaner_by_du-foo.pid

--pid_dir <pid dir>

Dir to create the pid file under.

Default: /var/run

-w <file>

Write the results out to this file.

-q

Don't print the results out.