cleanup

Purpose:

Remove old or excessive number of files.

Enter:

cleanup <max_age> <max_files> “file_filter” <percent> [-r]

Where:

max_age Specify the maximum file age in days.
max_files Specify the maximum number of files.
file_filter Specify a pathname file filter enclosed in quotes.
percent Optional. Specify the minimum disk percent used before cleanup is executed. default value is 0.
-r Optional. Specify recursion for subdirectories.

Example:

cleanup 7 100 “/data/compressed/1999*.hst”

The above command removes files in the /data/compressed/ directory which have the .hst extender and begin with 1999, if the files are older than 7 days and if the number exceeds 100. If the number of files exceeds 100, the oldest ones are removed until only 100 are left.

cleanup 7 1000 “/data/compressed/1999*.hst”

The above command removes all files in the /data/compressed/ directory which have the .hst extender, begin with 1999, and are older than 7 days. If the number of files exceeds 1000, the oldest ones are removed until only 1000 are left.

cleanup 7 1000 “/data/compressed/1999*.hst” percent=50

The above command removes all files in the /data/compressed/ directory which have the .hst extender, begin with 1999, and are older than 7 days if the percentage of disk space used is greater than 50. Oldest files are removed until only 1000 are left.

cleanup 7 100 “/data/hold/n*” -r

The above command removes n* files in the /data/hold/ directory and its subdirectories that are older than 7 days, up to a maximum of 100 files in all.

Notes:

A log of removed files will be written into a file named /data/cleaned_files.YYMMDD

See Also:

Usercron Utility