Remove Files
Last updated
Last updated
Copyright 2013-2024 60East Technologies, Inc.
AMPS provides the following module for removing files. Use this action to remove error log files that are no longer needed. AMPS loads this module by default.
This action removes files that match an arbitrary pattern. If the pattern is not specified carefully, this action can remove files that contain important data, are required for AMPS, or are required by the operating system.
This action cannot be used to safely remove journal files (also known as transaction log files). Use the actions described in Manage Transaction Log Journal Files for these files.
Module Name | Does |
---|---|
This module requires an Age
parameter that specifies the age of the files to remove, as determined by the update to the file. This module also requires a Pattern
parameter that specifies a pattern for locating files to remove.
Parameter | Description |
---|---|
This module does not add any variables to the AMPS context.
amps-action-do-remove-files
Removes files that match the specified pattern that are older than the specified age. This action accepts an arbitrary pattern, and removes files that match that pattern. While AMPS attempts to protect against deleting journal files, using a pattern that removes files that are critical for AMPS, for the application, or for the operating system may result in loss of data.
The module does not recurse into directories. It skips open files. The module does not remove AMPS journals (that is, files that end with a .journal
extension), and reports an error if a file with that extension matches the specified Pattern
.
The commands to remove files are executed with the current permissions of the AMPS process.
Age
(required)
Specifies the age of files to process. The module removes any file older than the specified Age
that matches the specified Pattern
.
For example, when the Age
is 5d
, only files that have not been modified within 5 days and that match the pattern will be processed by the module.
There is no default for this parameter.
Pattern
(required)
Specifies the pattern for files to remove. The module removes any files that match the specified Pattern
that have not been modified more recently than the specified Age
.
This parameter is interpreted as a Unix shell globbing pattern. It is not interpreted as a regular expression.
As with other parameters that use the file system, when the pattern specified is a relative path, the parameter is interpreted relative to the current working directory of the AMPS process. When the pattern specified is an absolute path, AMPS uses the absolute path.
There is no default for this parameter.
Keep
Specifies the number of files that meet the Age
and Pattern
criteria to retain. When this parameter is specified, AMPS will remove files matching the criteria, starting with the oldest files, and stop when the number of remaining files is the number specified in this parameter.
There is no default for this parameter. When both Keep
and Count
are specified, AMPS will not remove any files if the number of files meeting the criteria is less than the number specified in the Keep
parameter.
Count
Specifies the maximum number of files that meet the Age
and Pattern
criteria to remove. AMPS will remove files matching the criteria, starting with the oldest files, and stop when the number of files specified in this parameter have been removed.
There is no default for this parameter. When both Keep
and Count
are specified, AMPS will not remove any files if the number of files meeting the criteria is less than the number specified in the Keep
parameter.