CleanupLogsJob
extends MaintenanceJob
in package
Deletes old log files from the application log directory.
The default file log destination is append-only with no rotation, so log files grow unbounded. This job removes log files whose last-modified time is older than the configured retention window. The active log file is preserved because it is continuously written to and therefore stays within the window.
Arguments:
- max_age_days: retention window in days (default 30)
Table of Contents
Methods
- getName() : string
- run() : bool
- Delete log files older than the retention window.
- getBasePath() : string|null
- Resolve the application base path from the Registry.
- getConnection() : PDO|null
- Build a PDO connection from the application database settings.
- getSettings() : SettingManager|null
- Resolve the application SettingManager from the Registry.
- intArg() : int
- Read an integer argument with a default fallback.
- resolveLogDirectory() : string|null
- Resolve the directory that holds the application log files.
Methods
getName()
public
getName() : string
Tags
Return values
stringrun()
Delete log files older than the retention window.
public
run([array<string|int, mixed> $argv = [] ]) : bool
Parameters
- $argv : array<string|int, mixed> = []
Return values
bool —True on success.
getBasePath()
Resolve the application base path from the Registry.
protected
getBasePath() : string|null
Return values
string|nullgetConnection()
Build a PDO connection from the application database settings.
protected
getConnection() : PDO|null
Return values
PDO|null —Null when the connection cannot be established.
getSettings()
Resolve the application SettingManager from the Registry.
protected
getSettings() : SettingManager|null
Return values
SettingManager|null —Null when settings are unavailable.
intArg()
Read an integer argument with a default fallback.
protected
intArg(array<string|int, mixed> $argv, string $key, int $default) : int
Parameters
- $argv : array<string|int, mixed>
- $key : string
- $default : int
Return values
intresolveLogDirectory()
Resolve the directory that holds the application log files.
private
resolveLogDirectory() : string|null