Clean up after action scheduler

Sometimes the action scheduler can create huge database files that affect the performance of WordPress, and intervention is required. These queries can help clean up these tables.

Remove all rows from the table wp_actionscheduler_actions that contain the statuses complete, failed, or canceled:

DELETE FROM `wp_actionscheduler_actions` WHERE `status` IN ('complete','failed','canceled')

 

Clean up the log files:

TRUNCATE `wp_actionscheduler_logs`

 

Add to functions.php to change the purge from 30 days to 1 week:

add_filter( 'action_scheduler_retention_period', 'wpb_action_scheduler_purge' );
function wpb_action_scheduler_purge() {
	return WEEK_IN_SECONDS;
}

 

source: https://wpxss.com/database/how-to-cleanup-wp_actionscheduler_actions-wp_actionscheduler_logs-tables-in-the-database/

Scroll to Top