Command Line Parameters in VBScript Windows Scripting Host
A Crontab is a job that runs programs at their specified intervals. In Linux, you can use crontab -e to edit the jobs, e.g. normally a line specifies one job, for example,
*/5 * * * * /usr/bin/uptime > /var/www/helloacm.com/htdocs/uptime.txt |
*/5 * * * * /usr/bin/uptime > /var/www/helloacm.com/htdocs/uptime.txt
Adds a job that runs every 5 minute to redirect the output of command uptime to a text file.
For wordpress sites, there is indeed a wp-cron.php that locates at the root directory of your wordpress blog. Everytime the blog gets a visitor, it will trigger this file and check if there are jobs to do (e.g. should I do something?). If there is, then the PHP script will trigger a job in the background, which is claimed that it won’t slow down the page loading speed.
Does this slow down page loading speed? Probably not much or can be barely noticed any difference. However, as your traffic gets bigger, for each visitor, the server needs to check for cron jobs, which definitely increases the server processing time (server load).
So, why not put this under Linux crontab and disable that in wordpress. You can disable this in wordpress by adding the following to the wp-config.php
define('DISABLE_WP_CRON', true); |
define('DISABLE_WP_CRON', true);
And next is to add this to crontab using crontab -e , the following runs the wp-cron.php every 5 minutes (change this frequency accordingly if you are not satisfied)
*/5 * * * * cd /var/www/codingforspeed.com;php /var/www/codingforspeed.com/wp-cron.php > /dev/null 2>&1 |
*/5 * * * * cd /var/www/codingforspeed.com;php /var/www/codingforspeed.com/wp-cron.php > /dev/null 2>&1
We have to cd into the wordpress folder otherwise the wp-cron.php may fail silently. However, this seems fixed in the latest WordPress.
if ( !defined('ABSPATH') ) { /** Set up WordPress environment */ require_once( dirname( __FILE__ ) . '/wp-load.php' ); } |
if ( !defined('ABSPATH') ) { /** Set up WordPress environment */ require_once( dirname( __FILE__ ) . '/wp-load.php' ); }
You might also use curl or wget or do this:
curl https://helloacm.com/wp-cron.php |
curl https://helloacm.com/wp-cron.php
Alternatively,
wget https://helloacm.com/wp-cron.php > /dev/null 2>&1 |
wget https://helloacm.com/wp-cron.php > /dev/null 2>&1
You might want to check the 301 redirections if the URL specified has redirections. You can use the online utility at https://helloacm.com/curl/ .
我来评几句
登录后评论已发表评论数()