{"id":4167,"date":"2014-03-30T08:46:34","date_gmt":"2014-03-30T08:46:34","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/run-w3-total-cache-function-with-crontab-collection-of-common-programming-errors-2\/"},"modified":"2014-03-30T08:46:34","modified_gmt":"2014-03-30T08:46:34","slug":"run-w3-total-cache-function-with-crontab-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/run-w3-total-cache-function-with-crontab-collection-of-common-programming-errors-2\/","title":{"rendered":"Run W3 Total Cache Function with Crontab-Collection of common programming errors"},"content":{"rendered":"<p>Ok. I&#8217;m really stumped on this one.<\/p>\n<p>Basically, I need to call a function for the WordPress plugin W3 Total Cache as part of a cron job in crontab. I&#8217;d like to automatically clear the entire page cache nightly.<\/p>\n<p>Here&#8217;s the code that works fine within wordpress that I need to call:<\/p>\n<pre><code>if (function_exists('w3tc_pgcache_flush')) {\nw3tc_pgcache_flush();\n} \n<\/code><\/pre>\n<p>I&#8217;m currently using the following script:<\/p>\n<pre><code>#!\/usr\/bin\/php\n\n\n<\/code><\/pre>\n<p>and the command line:<\/p>\n<pre><code>php -q \/path-to-file\/flushtest.php\n<\/code><\/pre>\n<p>I used the wp_mail function to test and make sure I&#8217;m getting something.<\/p>\n<p>The script is working fine except that the page cache is never flushed. I get the email and there aren&#8217;t any errors in the log either.<\/p>\n<p>Any ideas?<\/p>\n<p>Thanks for your help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ok. I&#8217;m really stumped on this one. Basically, I need to call a function for the WordPress plugin W3 Total Cache as part of a cron job in crontab. I&#8217;d like to automatically clear the entire page cache nightly. Here&#8217;s the code that works fine within wordpress that I need to call: if (function_exists(&#8216;w3tc_pgcache_flush&#8217;)) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4167","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4167"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4167\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}