Skip to content
Last updated

Development Guides Home >> Guide to Standardized Hooks >> Hookable Events

Guide to Standardized Hooks - Log::Retention Functions

The Log::Retention category's events occur when you run the /usr/local/cpanel/scripts/log_retention script.

Note:

These events do not currently support custom user paths.

Information

  • Action code runs as: root
  • Blocking attribute: Unavailable
  • Escalate privileges attribute: N/A

Available stages

  • pre — Hook action code runs before the script deletes files.
  • post — Hook action code runs after the script deletes files.

pre_deletion

Use this event to archive or backup files before the script removes them.

Returns

The pre_deletion event returns the following values:

ReturnDescriptionExample
log_typeThe type of logs to process.web
userUsername for user logs, or undef for system logs.example
base_pathThe base directory to process./var/log/example-logs
files_to_deleteArray reference of files to delete.['/var/log/example-logs/log.1.gz', '/var/log/example-logs/log.2.gz']
retention_daysConfigured retention period in days.7

post_deletion

This event runs after the script deletes files.

Returns

The post_deletion event returns the following values:

ReturnDescriptionExample
log_typeThe type of logs processed.web
userUsername if processing user logs, or undef for system logs.example
base_pathBase directory processed./var/log/example-logs
deleted_countNumber of files deleted.4
retention_daysConfigured retention period in days.7