{"id":23095,"date":"2021-02-09T15:51:43","date_gmt":"2021-02-09T07:51:43","guid":{"rendered":"https:\/\/cloudwp.pro\/?p=23095"},"modified":"2021-02-12T18:06:11","modified_gmt":"2021-02-12T10:06:11","slug":"fast-remove-woocommerce-scheduled-actions","status":"publish","type":"post","link":"https:\/\/cloudwp.pro\/blog\/woocommerce\/fast-remove-woocommerce-scheduled-actions\/","title":{"rendered":"\u5feb\u901f\u6e05\u9664 WooCommerce Scheduled Actions"},"content":{"rendered":"
Scheduled Actions (\u5df2\u6392\u7a0b\u52d5\u4f5c) \u6703\u7528\u4f86\u8655\u7406\u548c\u8a02\u55ae\u76f8\u95dc\u7684\u6392\u7a0b\u5de5\u4f5c\uff0c\u7576\u57f7\u884c\u5b8c\u6392\u7a0b\u5de5\u4f5c\u4e4b\u5f8c\uff0c\u4e5f\u6703\u5c07\u5b8c\u6210\u5de5\u4f5c\u7684\u7d00\u9304\u5132\u5b58\u5728\u8cc7\u6599\u5eab\u4e2d\uff0c\u4f46\u9577\u6642\u9593\u7d2f\u7a4d\u4e0b\u4f86\uff0c\u5132\u5b58\u8a18\u9304\u7684\u8868\u55ae\u5c31\u6703\u8b8a\u6210\u975e\u5e38\u7684\u81c3\u816b\uff0c\u9032\u800c\u76f4\u63a5\u5f71\u97ff\u8cc7\u6599\u5eab\u7684\u6548\u80fd\u3002<\/p>\n
<\/p>\n WooCommerce \u672c\u8eab\u6709\u8003\u616e\u5230\u9019\u500b\u96b1\u6027\u554f\u984c\uff0c\u6240\u4ee5\u4e5f\u6709\u8a2d\u7f6e\u4e86\u81ea\u52d5\u6e05\u9664\u7d00\u9304\u7684\u6a5f\u5236\uff0c\u65b9\u5f0f\u70ba\u91dd\u5c0d\u5b58\u653e\u8d85\u904e\u4e00\u500b\u6708\u7684\u7d00\u9304\uff0c\u4e00\u689d\u4e00\u689d\u7684\u522a\u9664\uff0c\u4f46\u9019\u500b\u65b9\u5f0f\u5c0d\u65bc\u8a02\u55ae\u91cf\u589e\u9577\u5feb\u901f\u7684\u5546\u5e97\u4e26\u4e0d\u592a\u6709\u6548\u7387\uff0c\u56e0\u70ba\u4e5f\u6709\u5176\u5b83\u5916\u639b\u540c\u6642\u5728\u65b0\u589e\u5225\u7684\u5de5\u4f5c\u6392\u7a0b\uff0c\u7136\u800c\u6392\u7a0b\u589e\u52a0\u7684\u901f\u5ea6\u9084\u53ef\u80fd\u6703\u5927\u65bc\u522a\u9664\u7684\u901f\u5ea6\uff0c\u4e00\u4f46\u53c8\u9047\u5230\u8a02\u55ae\u91cf\u5927\u7684\u6d3b\u52d5\u6642\uff0c\u5c31\u6703\u5f71\u97ff\u8cc7\u6599\u5eab\u7684\u6548\u80fd\u3002<\/p>\n \u7531\u4e0a\u65b9\u7bc4\u4f8b\u5716\u7247\u78ba\u8a8d\u76f8\u95dc\u8cc7\u6599\u5eab\u7684\u8868\u55ae\u5927\u5c0f:<\/strong><\/p>\n \u6211\u5011\u5206\u4eab\u5e7e\u7a2e\u53ef\u4ee5\u6e05\u9664 Scheduled Actions \u7684\u65b9\u5f0f:<\/strong><\/p>\n 1.<\/strong> \u4f7f\u7528 phpMyAdmin \u9032\u884c\u522a\u9664\uff0c\u9019\u500b\u65b9\u5f0f\u6bd4\u8f03\u7c21\u55ae\uff0c\u53ef\u4ee5\u5728 SQL \u7684\u5340\u584a\u57f7\u884c\u4e0b\u5217\u6307\u4ee4\uff0c\u4e5f\u53ef\u4ee5\u767b\u5165 MySQL \u76f4\u63a5\u57f7\u884c\uff0c\u82e5\u662f\u7b2c\u4e00\u6b21\u4f7f\u7528\uff0c\u8acb\u5206\u958b\u8f38\u5165\u6307\u4ee4\u57f7\u884c\u4ee5\u78ba\u4fdd\u5b89\u5168:<\/p>\n 2.<\/strong> \u7528\u77ed\u8a9e\u6cd5\u7684\u65b9\u5f0f\u5b9a\u671f\u81ea\u52d5\u522a\u9664\uff0c\u53ef\u8a2d\u70ba\u6bcf\u65e5\u6216\u662f\u6bcf\u9031\u9032\u884c\u6e05\u7406\uff0c\u4f9d\u64da\u5546\u5e97\u7684\u72c0\u6cc1\u9078\u64c7\u4f7f\u7528\u5373\u53ef:<\/p>\n 3.<\/strong> \u8b93\u80fd\u5920\u767b\u5165\u4f3a\u670d\u5668\u7684\u7ba1\u7406\u54e1\u5feb\u901f\u6e05\u9664\u7684\u65b9\u5f0f\uff0c\u4e5f\u53ef\u4ee5\u5229\u7528 Cronjob \u57f7\u884c\uff0c\u9019\u500b\u65b9\u5f0f\u96d6\u7136\u65b9\u4fbf\uff0c\u4f46\u4e0d\u5efa\u8b70\u628a\u8cc7\u6599\u5eab\u5bc6\u78bc\u5b58\u5728\u8173\u672c\u4e2d\uff0c\u8acb\u5148\u81ea\u884c\u8a55\u4f30\u98a8\u96aa\u5f8c\u518d\u8003\u616e\u662f\u5426\u63a1\u7528\u3002<\/p>\n Scheduled Actions (\u5df2\u6392\u7a0b\u52d5\u4f5c) \u6703\u7528\u4f86\u8655\u7406\u548c\u8a02\u55ae\u76f8\u95dc\u7684\u6392\u7a0b\u5de5\u4f5c\uff0c\u7576\u57f7\u884c\u5b8c\u6392\u7a0b\u5de5\u4f5c\u4e4b\u5f8c\uff0c\u4e5f\u6703 […]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[75],"tags":[81,163,164],"class_list":["post-23095","post","type-post","status-publish","format-standard","hentry","category-woocommerce","tag-mysql","tag-phpmyadmin","tag-164"],"yoast_head":"\n$ wp db size --tables --human-readable\r\n\r\n+----------------------------------+--------+\r\n| Name | Size |\r\n+----------------------------------+--------+\r\n| wp_actionscheduler_actions | 122 MB |\r\n| wp_actionscheduler_logs | 66 MB |\r\n+----------------------------------+--------+\r\n<\/pre>\n
DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'complete';\r\n\r\nDELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'canceled';\r\n\r\nDELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'failed';\r\n<\/pre>\n
\/\/ \u6bcf\u65e5\u5b9a\u671f\u81ea\u52d5\u6e05\u9664 Scheduled Actions\r\nadd_filter( 'action_scheduler_retention_period', 'cw_action_scheduler_purge_daily' );\r\nfunction cw_action_scheduler_purge() {\r\n return DAY_IN_SECONDS;\r\n}\r\n<\/pre>\n
\/\/ \u6bcf\u9031\u5b9a\u671f\u81ea\u52d5\u6e05\u9664 Scheduled Actions\r\nadd_filter( 'action_scheduler_retention_period', 'cw_action_scheduler_purge_weekly' );\r\nfunction cw_action_scheduler_purge() {\r\n return WEEK_IN_SECONDS;\r\n}\r\n<\/pre>\n
#!\/bin\/bash\r\nuser=\r\npassword=\r\ndatabase=\r\nhost=\r\n\r\necho 'DELETE FROM `wp_actionscheduler_actions` WHERE `status` = \"complete\";' | mysql --user=\"$user\" --password=\"$password\" --database=\"$database\" --host=\"$host\"\r\necho 'DELETE FROM `wp_actionscheduler_actions` WHERE `status` = \"canceled\";' | mysql --user=\"$user\" --password=\"$password\" --database=\"$database\" --host=\"$host\"\r\necho 'DELETE FROM `wp_actionscheduler_actions` WHERE `status` = \"failed\";' | mysql --user=\"$user\" --password=\"$password\" --database=\"$database\" --host=\"$host\"\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"