martedì 18 dicembre 2012

Automating Wordpress wp-cron on debian

https://blog.giuseppeurso.net/wp-content/uploads/2012/12/time-300x224.jpg

timeSome simple steps to automate the execution of wp-cron.php.

Advantages:

  • You can schedule it at convenient hours without affecting performance for users
  • wp-cron.php become more reliable for almost time-critical tasks (updates, autopost, etc)


2 steps are needed:

  1. Disable the wp-cron execution from wordpress, in the wp-config.php file
  2. Edit your crontab by remote shell

How to disable wp-cron in wp-config.php:
open wp-config.php with your text editor and just add the following line at the end of the file:

 define('DISABLE_WP_CRON', true); 

please pay attention in order to avoid blank spaces or newlines at the end of the file, and yes, it is normal that the php closing tag is missing.
Save (and upload if you need to) and here we have done.

How to setup a cronjob for wo-cron in Debian Crontab.
Log into your machine and open the user cronjob typing:

 crontab -e 

when your crontab will open just paste a line like following adjusting your path to the real one.

 */50 * * * * wget http://blog.giuseppeurso.net/wp-cron.php?doing_wp_cron > /dev/null 2>&1 

On this page another approach is proposed and it would be useful for those who want to manage multiple cronjobs at time, but as you probaby already know, one of the advantages coming from using cron is to distribute tasks (the heavyest) in order to not affect (or at least try not affect) the average system performances.
Anyway the solution proposed is to schedule a php file containing the code needed to run the job.

Hope this help
Ciao!


Automating Wordpress wp-cron on debian

Nessun commento:

Posta un commento