How to upload a file to another server using cURL and PHP?

Does it work to trigger wp-cron.php with real cron jobs with the php command?

  • I'm working on a server that disables the wget and curl commands so looking for a way to do cron jobs with the php command. Some articles introduce a way to load the wp-cron.php file with the php command rather than curl or wget. http://chriswiegman.com/2012/04/stop-wp-cron-wordpress-cron-jobs-from-firing-on-every-page-load/ 0,10,20,30,40,50 * * * * /usr/bin/php /home/webuser/public_html/wp-cron.php >/dev/null 2>&1 https://rtcamp.com/tutorials/wordpress/wp-cron-crontab/ */10 * * * * cd /var/www/example.com/htdocs; php /var/www/example.com/htdocs/wp-cron.php > /dev/null 2>& In these cases, I suppose the $_POST array will not be sent. However, in wp-cron.php, there is the line that checks it: if ( !empty($_POST) || defined('DOING_AJAX') || defined('DOING_CRON') ) die(); So I'm wondering if the above methods would work or not.

  • Answer:

    What you can do is define a rewrite rule. Ping that end point with the real cron. And then have WP "listen" for that ping and then act accordingly. Just make sure you do some validation on that ping / msg else you should be on the short end of a DOS attach or similar. The WP Cron isn't a real cron. It more like a "if there's traffic and X has happened in the defined time since the last visit then do X." No visits = no X. More or less in a nut shell.

Mark Simchock at Quora Visit the source

Was this solution helpful to you?

Other answers

I'm the one who posted the question. They seem to work. I just misunderstood that this part !empty($_POST) would deny the direct access but it wasn't (it was opposite).

Anonymous

You can use this useful WordPress module to create cron: https://wordpress.org/plugins/easycron/.

Luo Li

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.