Clear WordPress Scheduled Action Logs
How to clean up the wp_actionscheduler tables when WooCommerce or other plugins fill your database with millions of completed action rows.
If your WordPress database has grown to hundreds of megabytes or even gigabytes, check the Action Scheduler tables. WooCommerce and several other plugins use Action Scheduler to run background tasks. It logs every completed action, and these logs pile up fast.
The Problem
Action Scheduler stores records in these tables:
wp_actionscheduler_actions– every scheduled, running, and completed actionwp_actionscheduler_logs– detailed logs for each actionwp_actionscheduler_groups– action groupingswp_actionscheduler_claims– processing claims
On a busy WooCommerce store, the actions table can grow to millions of rows, making the database slow and backups huge.
Check Your Table Sizes
In phpMyAdmin, look at the row count and size of the Action Scheduler tables. Or run:
SELECT table_name, table_rows,
ROUND(data_length / 1024 / 1024, 2) AS data_mb
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND table_name LIKE '%actionscheduler%'
ORDER BY data_length DESC;
If wp_actionscheduler_actions has more than 50,000 rows, it’s time to clean up.
How to Clean Up
Option 1: WooCommerce Settings (Preferred)
WooCommerce 7.0+ has a built-in setting to control log retention:
- Go to WooCommerce > Status > Scheduled Actions
- Check the “Complete” tab – this shows finished actions
- WooCommerce should automatically clean up completed actions after 30 days
If it’s not cleaning up on its own, your site’s cron may not be running:
# Check if WP-Cron is disabled
grep DISABLE_WP_CRON wp-config.php
If DISABLE_WP_CRON is set to true, you need a real server cron job to trigger it. In cPanel, add a cron job:
*/5 * * * * cd /home/username/public_html && php wp-cron.php > /dev/null 2>&1
Option 2: SQL Cleanup (Faster)
Delete completed and canceled actions older than 7 days:
-- Delete old completed action logs first (foreign key dependency)
DELETE l FROM wp_actionscheduler_logs l
INNER JOIN wp_actionscheduler_actions a ON a.action_id = l.action_id
WHERE a.status IN ('complete', 'canceled')
AND a.scheduled_date_gmt < DATE_SUB(NOW(), INTERVAL 7 DAY);
-- Then delete the completed actions themselves
DELETE FROM wp_actionscheduler_actions
WHERE status IN ('complete', 'canceled')
AND scheduled_date_gmt < DATE_SUB(NOW(), INTERVAL 7 DAY);
-- Optimize the tables afterward
OPTIMIZE TABLE wp_actionscheduler_actions, wp_actionscheduler_logs;
Back up your database first. Always download a copy before running bulk DELETE operations.
Option 3: WP-CLI
If you have SSH access and WP-CLI installed:
wp action-scheduler clean --batch-size=1000 --status=complete
Or use a direct database query through WP-CLI:
wp db query "DELETE FROM wp_actionscheduler_actions WHERE status = 'complete' AND scheduled_date_gmt < DATE_SUB(NOW(), INTERVAL 7 DAY);"
Prevent Future Buildup
Add this to your wp-config.php to reduce the retention period:
// Keep completed actions for only 1 day instead of 30
define('ACTION_SCHEDULER_RETENTION_PERIOD', DAY_IN_SECONDS);
Or set it to 0 to delete completed actions immediately (not recommended for debugging):
define('ACTION_SCHEDULER_RETENTION_PERIOD', 0);
Related Articles
- Remove Leftover WordPress Plugin Data
- Database Management in cPanel
- Slow Website Performance
- WordPress Hosting - optimized hosting for WordPress sites
Last updated 19 Apr 2026, 23:46 +0300.