Removing Scheduled Actions from WooCommerce Action Scheduler

The Scheduled Actions that sit in WooCommerce Action Scheduler can get stuck with thousands of actions piling up, just stuck in a failed, canceled, pending or complete state. This can result in bloated database tables in particular wp_actionscheduler_actions and wp_actionscheduler_logs tables.

Woocommerce Scheduled Actions

Large number of canceled, failed and completed Scheduled Actions


Since the states of failed, canceled or complete are already passed, you would be safe to remove them from the wp_actionscheduler_actions table. You can do so in phpMyadmin SQL tab.

Woocommerce Scheduled Actions Database Table

Removing all canceled actions.


Just use the state required in the SQL command…

DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'canceled'
DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'failed'
DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'complete'

For scheduled actions that are pending you can use the same SQL commands as above just change the status to pending, but you would probably leave these to run in time or if they are overdue then run them from within WooCommerce.


Woocommerce Scheduled Actions Pending Run

Run pending actions now


wp_actionscheduler_logs Table

If the wp_actionscheduler_logs table is bloated, just empty it.

Woocommerce Scheduled Actions Log Table

Empty the log table


Completed Actions

Completed actions are normally removed by the Action Scheduler after 30 days by default but there is a filter that can change that setting  –action_scheduler_retention_period, use it like so in functions.php

add_filter( 'action_scheduler_retention_period', 'wpb_action_scheduler_purge' );
 * Change Action Scheduler default purge to 1 week
function wpb_action_scheduler_purge() {


  1. Simone Longato on February 1, 2022 at 2:07 pm

    Thank you! I bought this system on a site that I manage. I then cleaned the database by deleting the lines, because it gave me an error in entering the code.
    But now the database certainly weighs less!
    A thousand thanks

  2. Shams Uz Zaman on January 7, 2022 at 9:33 am

    My wordpress website database causing an error of Error establishing a database connection the hosting provider told that wp_actionscheduler_logs of your database table create an issue.
    Can I empty that?

  3. Dresuar on March 30, 2021 at 11:09 am

    it worked for me, Very helpful. thank you very much

  4. Juan Villegas on March 24, 2021 at 3:06 pm

    It is worth to mention another filter: action_scheduler_cleanup_batch_size

    The default batch size value is 20, it means that 20 completed tasks are removed from the DB in every clean up.

    If your website generate a lot of tasks, maybe a batch size of 20 is not enough, so you can do something like this to increase the value to 100, or whatever you need:

    function my_plugin_action_scheduler_cleanup_batch_size($batch_size = 20) {
    $batch_size = absint($batch_size);

    return max(100, $batch_size);
    add_filter(‘action_scheduler_cleanup_batch_size’, ‘my_plugin_action_scheduler_cleanup_batch_size’);

  5. Morgan on November 28, 2020 at 4:17 am

    Added to my list for routine database optimization.

    Thank you for this simple useful post

  6. Wesley Carnicle on September 10, 2020 at 11:49 am

    How can it be re installed if it was deleted

  7. Josh on July 22, 2020 at 8:48 pm

    But why is it happening in the first place??
    My webhost limits DBs to 1GB and when this happens, they lock our DB until I empty the table. I need to know what the root cause is. Anyone know?

  8. Nick on June 18, 2020 at 11:24 am

    Thanks for your post. You can run all 3 quickly with `DELETE FROM `wp_actionscheduler_actions` WHERE `status` IN (‘canceled’, ‘failed’, ‘complete’);`

  9. Scott on June 4, 2020 at 6:57 pm

    Hi, thanks for writing on this topic. I find that every time I update Woocommerce, on nearly every store I have, the database updates never finish on their own, and I discover many pending actions stuck in the scheduler. Is this common? If not, what issues should I be looking for that would cause this?

  10. Brigitte on April 14, 2020 at 2:21 pm

    Thank you so much for this useful contribution. I used it already a few times. Very helpful!

Leave all Comment