3 min read

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 action
  • wp_actionscheduler_logs: detailed logs for each action
  • wp_actionscheduler_groups: action groupings
  • wp_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: Automatic Cleanup (Preferred)

Action Scheduler deletes completed actions older than 30 days on its own, as long as WP-Cron runs. WooCommerce has no setting for this. To check:

  1. Go to WooCommerce > Status > Scheduled Actions
  2. Open the “Complete” tab, which shows finished actions
  3. If you see completed actions much older than 30 days, the automatic cleanup isn’t running

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

On a VPS, Business Cloud or dedicated server with WP-CLI installed (shared and WordPress plans have no shell, so use Option 2 in phpMyAdmin there):

  wp action-scheduler clean --batch-size=1000 --status=complete
  

If you’d rather run raw SQL from the command line, run the Option 2 queries with wp db query, logs first. Deleting only the actions leaves their rows in wp_actionscheduler_logs behind. If your table prefix isn’t wp_, change it in every table name.

Prevent Future Buildup

The retention period is set with the action_scheduler_retention_period filter, not in wp-config.php. Create a must-use plugin at wp-content/mu-plugins/as-retention.php (create the mu-plugins folder in File Manager if it doesn’t exist):

  <?php
// Keep completed actions for only 1 day instead of 30
add_filter( 'action_scheduler_retention_period', function () {
    return DAY_IN_SECONDS;
} );
  

Must-use plugins load automatically, with no activation step. Keep at least a day of history, so you can still see what ran when you’re debugging a failed task.

Last updated 21 Oct 2026, 00:00 +0300. history

Was this page helpful?