WordPress uses a file called wp-cron.php as a virtual cron job in order to automate tasks like publishing scheduled posts, checking for plugin or theme updates, sending email notifications, and more.
Why would you disable the WP-cron (wp-cron.php)? For many WordPress users, you can improve website performance when you disable the WP-cron in the WordPress site configuration file. This reduces the number of times that scheduled tasks are performed which lessens the load on the server.
There are also possible exploits that can affect the wp-cron.php file. Disabling the WP-cron can tighten security by preventing these possible exploits from affecting your WordPress installation.
- Why the WP-Cron is a Performance Problem
- Disable Default WP-Cron Behavior
- Set up Manual Cron Job in Place of WP-Cron
- Plugin Solutions for Managing the WP-cron
- Understanding “doing_wp-cron” Errors
- Possible Exploits Affecting WP-Cron
Why the WP-Cron is a Performance Problem
The WP-Cron is triggered any time that a visitor loads a page on your WordPress site. Some of the tasks that are triggered include:
- Check for updates
- Publish scheduled posts
- Check for notifications from plugins
The load on the server processor and resources are affected by the list of tasks that need to be checked by WP-Cron whenever a page is visited. The longer the list of tasks and the larger the volume of content, the more the server is affected.
So, if you have a larger website with a lot of content, then these scheduled tasks could be substantial enough to affect your server performance. You can then improve performance by disabling the wp-cron and scheduling your tasks so that they don’t run every time that a page on your WordPress site is loaded.
Disable Default WP-Cron Behavior
Using the steps below we can disable the WP-Cron (wp-cron.php) in the wp-config.php file.
- Open your wp-config.php using cPanel File Manager or FTP.
- Find the line that starts with “$table_prefix.” Hit your enter key to add a line under that statement. Then add the following code:
/** Disable the WP_CRON processes*/
define('DISABLE_WP_CRON', true); - Click Save.
Now WordPress will not automatically run the wp-cron.php script each time your site gets a new visitor. Since the wp-cron is disabled, you will need to make sure that you set up a solution such as a manual cron job or plugin to make sure that your normally scheduled tasks are still being run. Follow the steps below for setting up a manual cron job and for some plug-in options.
Set Up Manual Cron Job in Place of WP-Cron
We don’t want to leave WordPress without any ability to automate tasks it might need to do. But at least now that it’s not running for every single visitor, we can have more control over when these tasks take place. For most WordPress users, having the wp-cron.php script run every 6 hours is perfectly fine. That would be just 4 executions in a day, compared to possibly hundreds, or even thousands if you had a lot of website traffic that day.
- Log into cPanel.
- Under the Advanced section, click on Cron Jobs.
- Select Once per hour from the Common Settings drop-down.
- Now select Every Sixth hours from the Hour drop-down.
- Finally fill in the code to run our cron job and click Add New Cron Job.
cd /home/userna5/public_html; php -q wp-cron.php
Where userna5 is your cPanel user name. Keep in mind that the /home/userna5/public_html path would be for a primary domain, if you’re using an add-on domain, or have WordPress installed in a sub-directory you’ll want to be sure to update your path by adding it to your script or editing the command line. - You should see that your new cron job was added successfully.
Now your WordPress website should be safely running scheduled tasks via the wp-cron.php script, but only at set intervals. If you aren’t receiving an email when the cron runs, see our guide on cron job not emailing me.
Plugin Solutions for Managing the WP-cron
Like most issues on WordPress, there is often a plugin that has been created in order to address the problem. These free plugins allow you to control or monitor the cron jobs run by the WP-cron. With this functionality, these plugins let you know when there are issues with WP-cron because you can see what’s happening to the cron jobs. The first 2 plugins allow you to add, edit, delete cron jobs as part of their basic functionality. They also include many other functions such as scheduling.
The last plugin simply gives you a status of the existing cron jobs being run by WordPress. There are many more plugins than the three that are listed here. However, we have listed the three with the most active installations per the WordPress.org site. This is a quick summary of each of the plugins:
Advanced Cron Manager – Debug & Control
Controls WordPress cron events. You can search for events, add new events, manually execute events, pause events, and much more. There is also an extensive scheduling option.
There is a pro version of the plugin that provides this additional functionality:
- Cron Logger – log cron’s execution times easily
- Events rescheduling – change event next execution date to control server load
- Error catcher – catch cron task’s fatal errors and get them displayed in the log
- Performance stats – see how much time and memory particular event took
- Debug tool – log any useful informations from Cron callback
This plugin does not disable the WP-cron but like the other plugins in this review, it provides control over the cron jobs running on your site.
Allows you to view and control what’s happening in the WP-Cron system. This plugin is the most recently updated and tested to WordPress version 5.8.
- View all cron events, recurrence, callback functions, and scheduled run date
- Edit, delete, and run any cron events
- Add, delete cron events and schedules
This plugin does not disable the WP-cron, but it gives you control over the cron jobs it manages. This is an open-source application and does not have a pro version.
You can see tasks that have been successfully run and those that did not. This gives you an overview that can help you decide on any necessary actions. This is a great troubleshooting tool and extremely helpful when tracking issues identified as problematic.
This plugin does not disable the WP-cron. It is used to carefully monitor the tasks managed by the WP-cron so that you can see what is happening. You can then easily see the cron jobs status and get an emailed status when issues occur.
There is a pro version that gives you the ability to store more than 3 logs, store them for longer periods, and get more frequent email updates.
Understanding “doing_wp_cron” Errors
WP-Cron job errors generally show up in a URL that looks like this:
https://example.com/post-name?doing_wp_cron=1245821
As we have previously stated, the automated tasks executed through wp-cron.php occur when a visitor views your WordPress site. At that time, these automated tasks are supposed to run, but sometimes things can go wrong. A plugin may not work correctly, or an automated task may work incorrectly. At worst, a task like publishing a scheduled post could happen more than once. Duplicate content – especially if it happens in large numbers – can be bad for your website due to the effect it has on your search engine results.
The best solution is to disable the WP cron jobs as we have discussed above or to use a plugin. You can easily see these error messages using a plugin or even the new Site Health tools included with WordPress. The WP-Cron Status Checker is a good plugin to use to specifically see if errors are occurring.
Congratulations! You now have a better understanding of the issues caused by the WP-Cron job (wp-cron.php). You also have solutions that can be applied when you have heavy traffic through code or by a plugin. This will help improve your WordPress site performance!
Possible Exploits Affecting WP-Cron
Cybercriminals are also aware of how the wp-cron.php file affects a WordPress site. They can manipulate a site using the WP-cron to perform a denial of service attack (DoS) in order to slow down a website or bring it down.
A Denial-of-Service (DoS) attack is an attack meant to shut down a server or network, in order to make it inaccessible.
Older versions of WordPress have also been subject to SQL injection attacks using the wp-cron.php file to attack the WordPress database.
SQL injection is a type of cyber attack that is used to manipulate a database to gain access or destroy valuable/private database information.
If you are aware that your WordPress site is subject to high traffic, then it is recommended that you disable the wp-cron.php file so that it does not run every time a visitor views your site. If your site is small and you only get a few visitors on the hour, then it will not be a problem.
Improve the performance and security of your WordPress website with our Managed WordPress VPS Hosting plans.
Web Application Firewalls Free SSL Certificates Advanced Server Caching
I was just trying to add the code into the wp-cron file but the code is not there as stated in the solution here, which is:
So has hsomething changed in the standard wp-cron file? Where do I now insert the disable code for each time a visitor hits the website?
Thanks
The article above instructs to add the code to your wp-config.php file, not the wp-cron.php file. You should be able to see the code referenced in that correct file.
I’m concerned now that my line of code should have something instead of:
php -q wp-cron.php;
I set my cron job up just liek that. Is that OK? Did I need to edit anything else there?
Hello,
You should include the cd command and path to the WordPress installation. For example:
cd /home/userna5/public_html; php -q wp-cron.php
I hope this helps!
i would say:
php –no-header wp-cron.php;
instead of
php -q wp-cron.php;
so you can spare “technically-challenged” people like me the trouble of looking up what the “-q” option does.
Thank you for your comment!
works great as written on webhostface hosting environments.
Checked using your method of scheduling a post before the time the cron job kicks off. Asesome!
Mike
Thanks for your feedback!
To setup the manual cron job, the command in step 5 (cd /home/userna5/public_html; php -q wp-cron.php) is different from the instructions on my “add new cron job” page in cPanel. There it says:
———————————
PHP command examples:
General example:
/usr/local/bin/php /home/username/public_html/path/to/cron/script
Domain-specific example:
/usr/local/bin/ea-php56 /home/username/domain_path/path/to/cron/script
In the above example, replace “ea-php56” with the PHP version assigned to the domain you wish to use.
—————————-
So which command format is correct?
/usr/local/bin/ea-php56 should be used if you wish to control which version of PHP is used for the script you specify. /home/username/domain_path/path/to/cron/script is an example path to the script you would like to be run (using the version of PHP from the preceeding path).
You should use the following format:
/usr/local/bin/ea-php56 /home/username/path/to/cron/script
(replace “ea-php56” with the PHP version assigned to the domain you wish to use.)
Sorry for the problem with the Fatal error in your WordPress site. The problem appears to be an issue identified in WordPress 4.93. Per some support forums, the best way to resolve it is to upgrade to version 4.94. If you’re having a specific WordPress function issue you may need to speak with the developers of the affected plugin, or you may need to post the issue in the WP support form for further assistance.
if i update new post in site A.how to get same post in site B?
Why would you want to do that? That’s duplicate content as far as Google is concerned and would hurt the 2nd website that posts it.
Can i use this commend for all users in my account
If no please tell me how to configure for all cpanel users under my Dedicated server
Help me
Thanks
Yes, just change the userna5 to be the specific cPanel username you want to use it on.
It’s
Are there other things which could trigger wp-cron.php to run? I’ve implemented the fix you recommend and it greatly decreased the number of times wp-cron.php ran. But I’m still seeing it run more than expected. It’s running more times than the # of site visits plus the number of times the cron job is scheduled. It’s not even close. So I’m trying to figure out if maybe a theme or plugin could trigger it to run, and how I might track that down. Thoughts?
You could try enabling/disabling the plugins systematically. Likewise, you could switch to a default theme to see if either of these are affecting it.
HI I apologise if I missed the answer somewhere but I have over 300 addon domian sites and waswondering if there is a way to set the wp-cron.php without doing it 300 times. Can I do some sort of root account setting?
Thank you
It is likely possible with some cash scripting, however we do not have any scripts that perform that task currently.
If wp-cron.php is really being visited every time someone vists a page n your site then there is a na issue with the site that you need to investigate or you really have some functionality that is configured to create very frequent scheduled tasks. Simply disabling the WordPress cron doesn’t fix anything but just masks whatever the issue is and will cause otehr problems. You state that you “do not need” WordPress cron but on what grounds do you say this? WordPress Core itself uses the WordPress Cron mechanism for important aspects of site operation and many common and popular plugins also use this mechanism for aspects of their operation – by disabling WordPress cron you simply break all of this. So personally I would advise that you investigaet and fix the problem rather than mask it and also break other stuff in the proces, but of course the choice is yours.
Regards
Hi John,
Thanks for your reply, finaly this is the only article that works!
Another sites tell to put the code at the end of wp-config, well my wp-cron still working.
After I tried your tutorial to put the code under database setting, my wp-cron is completely off.
Btw, I’m using true only, without single quotation marks. I don’t know what is the different, I’m newbie in wordpress, but I’m really happy because finally my wp-cron is gone. I really hate that wp-cron, I don’t need it. lol
Before that wp-cron always running everytime when someone visit my web, so my CPU resource stable at 75-100%, now my CPU resource is stable at 0%-25%.
You guys are awesome! Thanks a lot, I’m really happy right now 😀
The correct version is ‘true’ or true ?
I tried both and wp-cron still active and show up everytime someone visit my site, so the cpu resource is going crazy.
It should be ‘true’ with single quotation marks.
Thank you,
John-Paul
I had installed the plugin backwup. my backup-way was ‘per email’. Because fro the start of the plugn,i got a lot of empty emails, I deinstallated an deleted the plugin, but the cron job ist still working, and it seems with every page load the job starts and sends me an email – I cannot find a way to stop the cron job, adding define(‘DISABLE_WP_CRON’, true); to wp-config didn’t help.
What would be the best way?
Thanks a lot for help!
Hello,
Do you have any caching installed? If so clear the cache and maybe disable it for now.
Best Regards,
TJ Edens
I’m experiencing the same issue and it is definitely connected to cron job being run. The rest of the time WordPress Simple Paypal Shopping Cart is working smoothly and without any errors.
This was super helpful! Thanks guys 🙂
I noticed that Webalyzer shows “hits” on wp-cron.php
Does this happen automatically or is someone trying to get into my wp-cron? I’m very concerned after being hacked at another web host, so I’m wondering whether I need to worry about this showing up
It is likely just bots. They crawl and hit common pages for whatever reason. wp_cron.php is in every WordPress site, so it could be just testing to see that it exists. Getting hit on any page is not an indication that it is being cased for a hack. Bots do all kinds of things for different reasons.
OK so what is the -q parameter for??
the -q switch sets the command to ‘quiet’ mode, which supresses output.
He’s right though. The tutorials tells you to set “Common settings” to 1 hours, and after that specifies every 6 hours. Doing this deletes the common setting. Step 3 is not needed. At least on the latest cpanel. Check you’ll see.
Thanks for your kind help, just a question in my head, how to check if it really worked or not?
You may have to check this against cron activity that was previously running.
Hi, I just wanted to leave an information here:
In some cases the wp-cron.php crashes on Windows Server + IIS the PHP.exe which produces an 500 error. You need than to recycle the application pool. So to fix this issue just disable wp-cron.php.
Hello,
Thanks…
My problem was solved using,
*/5 * * * * php /home/cpanelusername/public_html/yourcron.php
this type of command.
Now, my cron working properly.
Thanks again…
Hello Jerome,
As long as your code can access the data then there really shouldn’t be any reason that it would not work. For info on Crons, check out Running a Cron Job. We unfortunately can’t provide specific code support, we can try to help if you have specific questions.
I hope this helps to answer your question, please let us know if you require any further assistance.
Regards,
Arnel C.
Hi Scott,
Thank you for you reply.
Im trying to load a function inside a theme, to grab the data from a xml link.
And i want to know if this command from the cron is possible to grab data.
Regards,
Jerome
Hi,
I just want to know if i can run the file insde the theme like this.
php home2/username/public_html/folder/wp-content/themes/folder_name/file.php
Regards,
Jerome
Hello Jerome,
What exactly is it you are trying to do?
Kindest Regards,
Scott M
Hello,
I’m need to create a cron which in the midnight, but for testing i have simply created a cron which run after 5 mins is as bellow,
*/5 * * * * wget https://mysite.com/wp-cron.php?doing_wp_cron=1 > /dev/null 2>&1
but is not sending any mail to me related cron, so i’m very confuze that cron is set or not.Also i have aslo run the file in url but also not getting any mail.
I have refer,
https://wpdailybits.com/blog/replace-wordpress-cron-with-real-cron-job/74 link to set a cron
I’m working with wordpress site
Please provide me solution urgently.
Thanks inadvance
Hello Poojali,
Sorry for the problem with the your Cron job. Unfortunately, the “wget” command is disabled on shared servers. You will not be able to use that command in a shared server, so it most likely the main issue with your cron job. You can use the CURL instead. Check out how to create a CRON jobfor more info.
If you have any further questions or comments, please let us know.
Regards,
Arnel C.
By doing not so much if I set the following code in wp-config.php, is it sufficient?
define( ‘WP_CRON_LOCK_TIMEOUT’, 900 );
Hello,
Thank you for contacting us. While this may help, you will have to monitor your site over time to really know.
This is because everyone’s site performance can greatly differ based on what plugins/themes you are using and how much traffic.
Thank you,
John-Paul
Thanks for the article. I’ve been experiencing some brief timeouts that are happening in the wee hours of the morning on certain sites. After looking at the logs, I suspect the wp-cron combined with some system maintenance. At the very least this will narrow down the problem. But, hopefully, it will fix it.
Thanks!
Its pretty solid. nice work. I appreciate you taking the time to put this together.
Nothing it worked perfectly and was a great answer.
Hi Jacob,
If I disable the wp-cron.php, and set cron job for every 6 hours, would it effect the comment left by my visitors? Does the comment appear only at every 6 hours?
And also the scheduled post will be posted only 4 times a day?
Regards,
Joseph
It does not describe the consequences of turning off chron, why I might do so – especially since I have no idea what triggered the need to do so, as I do not get any serious volume on my site.
Hello,
This is what we have above: “On low traffic sites this is perfectly fine, but when visitors roll in, checking multiple times for scheduled tasks can be very inefficient and lead to resource usage problems for your server, plus make your website load slower.”
Did you have any more specific questions we can answer for you?
Kindest Regards,
Scott M
Hi Jacob,
Thanks for article. You save me from zombie.
Hello,
I keep getting this message
No input file specified.
Which later change to this, after i made some changes by adding my domain.
/usr/local/cpanel/bin/jailshell: line 0: cd: /home/xxxxxx/healthable.org/public_html: No such file or directory No input file specified.
Hello,
The path ‘/home/xxxxxx/healthable.org/public_html’ appears to be incorrect. It should be ‘/home/xxxxxx/public_html’ if your domain is the primary domain, or /home/xxxxxx/public_html/healthable.org’ if it is an addon domain.
Kindest Regards,
Scott M
Alright Thanks… let me try this.
Having lots of emails….
Warning: session_start(): Cannot send session cookie – headers already sent in /home/xxxxx/public_html/healthable.org/wp-content/plugins/maxblogpress-subscribers-magnet/maxblogpress-subscribers-magnet.php on line 632
Warning: session_start(): Cannot send session cache limiter – headers already sent in /home/xxxxx/public_html/healthable.org/wp-content/plugins/maxblogpress-subscribers-magnet/maxblogpress-subscribers-magnet.php on line 632
welcome
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/healthable.org/wp-content/plugins/maxblogpress-ping-optimizer/mpo-lib/include/mbp-ping-optimizer.cls.php on line 312
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/healthable.org/wp-content/plugins/maxblogpress-ping-optimizer/mpo-lib/include/mbp-ping-optimizer.cls.php on line 336
welcome
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/healthable.org/wp-content/plugins/maxblogpress-ping-optimizer/mpo-lib/include/mbp-ping-optimizer.cls.php on line 312
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/healthable.org/wp-content/plugins/maxblogpress-ping-optimizer/mpo-lib/include/mbp-ping-optimizer.cls.php on line 336
Fatal error: Cannot use object of type WP_Error as array in /home/xxxxx/public_html/healthable.org/wp-content/plugins/tweet-old-post/inc/core.php on line 641
Hello,
I am not quite sure of your situation. Are each of those separate emails or are you getting emails with nothing but errors? Some of the errors appear to be plugin related. This can be specific to that plugin or possibly caused by other plugins interfering. You will want to test each plugin individually and then together in combination to see if there are any interference.
Kindest Regards,
Scott M
I got the email just as i posted it
@Hansel – your article perpetuates the myth that wp-cron.php is caled by WordPress on every visit to a site. Rather than repeating falsehoods I would suggest you do your own homework, understand how it really works and then corect your article.
As for your technique, if you want to repeatedly call wp-cron.php for absolutely no reason and thus use more hosting resources rather than less then it’s up to you. I suppose if you actually have 144 WordPress scheduled tasks you want to run every day on every site you have then you may justify it – but do you really? If not then you are simply wasting resources and if you don’t understand why that might be the case then you might want to review your understanding of WordPress and how it handles scheduled tasks and what happens every time you call wp-cron.php when you don’t need to call it.
Regards
There is a nice cron wrapper script for executing every wp-cron.php in multi vhost setups: *Link Removed*
Hello Hansel,
Thank you for your suggestion. If you are interested in posting an article in our User Submitted section, I would be happy to link to it.
If you have any further questions, feel free to post them below.
Thank you,
John-Paul
I followed this advice after a support session. You bet it helped speed up the site, but what good is a fast site if it no longer does what it’s supposed to?
My calendar widget is no longer updating. It still thinks it’s yesterday. It’s also the backbone of my hyperlocal site. Back to support I go…
Hello Seth,
Thank you for contacting us. While disabling wp-cron can help speed up your site, it is just a suggestion.
If it is causing problems with your site, it may not be the best option.
Our guide on Optimizing WordPress provides several other suggestions for speeding up your site.
If you have any further questions, feel free to post them below.
Thank you,
John-Paul
is ok now. now watch the stats from recource usage ! thx
Ηι, i put the code exactly where the article says, but then in the main page i view only this…
Parse error: syntax error, unexpected T_STRING in /home/kafeneio/public_html/wp-config.php on line 1
Hello Panos,
Be sure to double check and ensure you followed the instructions correctly. If you feel so, then comment out the line you added. Does it still give an error?
Kindest Regards,
Scott M
Hi Jacob,
I renamed the adminold folder back to admin, I don’t remember renaming this folder, I will see what happens now.
I am getting the other error every 6 hours by email.
Andy.
I found that wp-cron.php continued to fire unless I placed the directive – define(‘DISABLE_WP_CRON’, ‘true’); – before this line:
Hello Andy,
Thanks for getting back to us, glad to hear that staggering the cron job runs seems to have gotten rid of your first issue.
For the first error that you’ve provided, it looks like it’s trying to run:
php -q /home/userna5/public_html/admin/cron.php
However it doesn’t look like you have a /public_html/admin/cron.php file, so that’s why it’s telling you No input file specified.
I see that you do have a /adminold directory, so possibly you forgot that you renamed this directory after setting up the cron job?
For the second error, it looks like your wire-writer.com cron run is failing due to the WordPress Simple Paypal Shopping Cart plugin that you’re running.
It says it has a problem with Line 13 of this file:
/home/userna5/public_html/wire-writer.com/wp-content/plugins/wordpress-simple-paypal-shopping-cart/wp_shopping_cart.php
Taking a look there I see this:
if (!isset($_SESSION)) {
session_start();
}
So it does seem related to something the plugin is trying to do with sessions. Doing a Google search of this issue I stumbled across this WordPress Simple PayPal Checkout Plugin Broken post on WordPress.org.
However I attempted to run that site’s wp-cron.php file directly and was not encountering this issue. So I’m not sure if it is tied somehow to it being run from a cron job which would be odd.
I see that the site’s cron job has run 3 times already today, are you encountering this error being emailed to you every time, or is it sporadic?
– Jacob
Hello Robert,
Yes the placement of the code in the wp-config.php file is important, that’s why in this guide it states to look around line 37 for the Database Collate section to place it directly under.
I’ll try to update the guide to make it a bit more clear that this is required. Thanks for the comment and letting me know!
– Jacob
Hi Jacob,
Reporting back ! I staggered those cron jobs like you said by 1 minute. I don’t get any emails with that error anymore, I just get two emails periodically as follows:
And this one:
Not sure about the first one, but the second one looks like an error!
Cheers,
Andy.
My website is loading slow on mobile devices which is causing a higher bounce rate. When I deactivated the plug in that is causing this I get an error message:
Warning Illegal offset in wp_includes cron.php file on line 180 …..
This is what is on line 180 – “if ( isset( $cron[ $hook ][ $key ] ) ) {“
Any suggestions??
Hey Andy,
Sorry for the delayed response, we have to approve comments on articles before you can see them to make sure people don’t include any sensitive information in their questions. So that’s why you didn’t see your comment posted right away.
If staggering the cron jobs so they don’t all run during the same minute works, please comment back here and let me know. I can go ahead and update this article itself for other users that have multiple WordPress installs to make sure they don’t run into the same problem if that’s the solution.
– Jacob
Hello Nathan,
What was the plugin that you deactivated that starting causing this error, and if you re-enable it, do the errors go away?
Most errors I see regarding Illegal offset in WordPress are from years ago. Are you running the latest version 3.9.1 of WordPress currently? You might want to try upgrading if not to see if that helps.
Otherwise it sounds like possibly your plugin that you had activated might have modified the cron.php script in a way that WordPress is not expecting. If that is the case, you can make a copy of your current /wp-includes/cron.php file and then download a copy of cron.php directly from WordPress to ensure you have a unmodified original version of it.
Please let us know if you’re still having any issues.
– Jacob
Hi Jacob,
Thanks for your reply, yes i have a bunch of wordpress addon domains for which i am following your guidelines to reduce cpu load on the shared server. So I just followed the instructions in the tutorial to manually add the cron jobs for each wordpress site.
I will try your suggestion and see if it makes a difference.
If not I will create a ticket to see why this is happening.
Cheers, Andy.
What does this mean? Emailed cron to me….
attempt to lock file /home/virtfs/_lock/889 timed out after 25 attempts; lock still held by pid 2170
Could not create lock file: /home/virtfs/_lock/889
Hello Andy,
Are you getting this error every single time the cron runs, or was this just a one-time thing? That error is in regards to the virtfs or Virtual Filesystem and seems to also be discussed here on the cPanel forums.
It basically sounds like a stale lock file, but I don’t see it on the server anymore. If you continue to see this issue pop up, please submit a ticket so that our system administration team can review why this might keep happening.
One way you might be able to prevent this from happening is by staggering your cron job runs as well. It looks like you have a bunch setup to all run every 6 hours at the top minute 0 of the hour. Maybe go up a minute for each to ensure that one can completely finish before another starts.
– Jacob
I get no errors at all when I visit truthsaves.org/wp-cron.php. I get nothing. No page load — just a blank page.
BUT . . . I have success using the curl method! THANK YOU! I am testing the curl method right now and was just able to get a scheduled post to work! And no error messages. Thank you very much!
when I try the wget method, I just get an error that I don’t have permission . . .
/usr/local/cpanel/bin/jailshell: /usr/bin/wget: Permission denied
Hello Eric,
Jacob means do you get an error message when visiting “https://example.com/wp-cron.php” itself?
Kindest Regards,
Scott M
Hello Eric,
That is correct, wget is disabled on our servers. You can, however use the cURL method. You can see the format for that here in our Cron job article.
Kindest Regards,
Scott M
Hi Jacob,
I don’t know what you mean when you say, “Do you get the same error when just trying to access the wp-cron.php script directly”
I did everything exactly as the article states.
When I disable the plugin I don’t get an email that anything has happened. No email so that must mean the cron job is running but wp-cron.php has nothing to do. As soon as I re-enable the plugin the error messages begin again.
I’m guessing this means the cron job is not running when that plugin is enabled?
Eric
getting the following errors running this cron job:
Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent in /home/userna5/public_html/wp-content/plugins/botdetect-wp-captcha/wp-botdetect-captcha.php on line 205
Apparently it’s connected to the botdetect captcha plugin. But I know nothing about this stuff. Does this mean the cron job is not running? Should I go back to using wp-cron.php? Or should I just ignore these errors?
Hello eric,
Do you get the same error when just trying to access the wp-cron.php script directly?
https://example.com/wp-cron.php
I installed that same WordPress plugin and was unable to get it to run into problems when running from a cron job. Are you using the same method as mentioned in this guide as:
If you disable the plugin does your cron job run without errors?
– Jacob
Unfortunately the original premise of the post is incorrect, which rather invalidates the main thrust of the topic.
If you would actually check in WordPress rather than simply regurgitate misinformation that you read elsewhere you would know that WordPress does not call wp-cron.php every time the site is visited. WordPress only makes a loopback access to wp-cron.php when there is a scheduled task due to run. I just thought I’d emphasise that so you’d be clear where the error in your original premise was.
In fact if you disable WordPress cron and instead rely upon server cron you can end up increasing the resource usage for a site. Just thought I’d emphasise that since the major claim of the post is the opposite. If you don’t understand why I suggest you run through some use case scenarios (and remember that a direct access to wp-cron.php is basically like any other site access and WordPress runs through it’s whole initialisation.
The simple example of having a server cron run 4 times a day may not increase resource usage but it certainly isn’t going to decrease it. But is 4 timesa day really valid for the type of high-traffic site that the example is pinned on? I would suggest considering something more realistic.
There is a place for a well targetted server cron to fire once at a specific time to trigger a periodic task that you know will be due at that time – but use this in conjunction with WordPress cron.
The only other time you might want to use a more frequent server cron is if the hosting doesn’t support http loopbacks and you are required to enable the WordPress alternate cron to haev WordPress cron work (if this is required then this is a bad host and you shouldmove anyway). This has the unfortunate side effect of sometimes making additional nasty query strings be visibly appended to urls that a site visitor might see and only in that case and only if you didn’t like that effect would you consider a more frequent server cron, but you’d have to take the hit of increased resource usage compared with using WordPress cron.
Regards.
Yup, as i have copied the code from above, there s space after cd . does it have to be there.
Hello Shan,
In the code provided, yes there should be a space after the cd.
cd /home/userna5/public_html; php -q wp-cron.php
If you have any further questions, feel free to post them below.
Thank you,
-John-Paul
I copy pasted ur code above, changed user and added /wordpress after public html. Later came back to add email. However is there a possibilty of cron file having a different name
The wp-cron.php file is always in the same place within the WordPress installation. Be sure that the path you are referencing in your cron job is the exact path of your WordPress installation.
I used this method, and added wordpress to the root after username, but i get an email saying NO input file specified. and i get it after every hour.
This means that your reference to the file is broken. Could you provide me with the exact line of code that you have in there for your cron job?
Generally it’s better to trigger cron from the command line than web because web often has a more limiting max execution time than command line.
I do have a *real* cron job on that site, however it runs only once per day at 3am, but it has nothing to do with wp-cron.php.
If you’ve followed the steps here correctly to disable it, the only person who would be able to give you accurate information on it would be your host.
Hello Dorian,
If you’ve disabled the WordPress wp-cron.php inside the wp-config.php file, but it’s still running, this could be caused by one of your plugins. Especially if it is a matter of your wp-cron.php script hanging and causing a lot of usage.
If you are on a cPanel host you should be able to access your raw access logs and take a look for the wp-cron.php requests in you logs.
This might help you narrow down what is still triggering your wp-cron.php executions even though they are disabled upon running every visit.
– Jacob
My host sent me a message 15 days ago saying that “multiple wp-cron processes running from previous days” had caused a resource shortage on my server. A quick google search led me to your website and I applied the line of code in wp-config.php exactly where you suggested. This morning there is another warning message in my inbox saying the same website’s wp cron had caused a resource shortage. I checked wp-config.php and verified that I had entered the code correctly.
Any suggestions why wp cron is still doing this despite that it has been disabled?
This line within your wp-config.php file will completely disable the wp-cron. It is, however, possible that if you set up the additional cron job, that you set it to run too frequently.
If you only disabled the wp-cron and are still getting these messages, I recommend speaking with your host for more information as it should no longer be running anymore.
Hi Jeff,
OK… It sounds like the correct path is to the location of the actual wp-chron.php file.
I think the misscommunication is about giving WordPress it’s own folder – routine for me as it’s a small but incremental plus for security.
Here’s the wordpress.org skinny on it.
https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Thanks again!
Hello Ken,
Thanks for the additional information.
Kindest Regards,
Scott M
Hi Jeff,
Sorry to be a pain… But I’m not absolutely sure we are on the same page. If you’ll indulge me, I’ll see if I can do this more graphically.. I’ll use 3 sites in the example but only “flesh out #2 as my poster child. Each site is a separate addon domain.
public_html
wordpress-site-folder-1 (abc.com)
wordpress-site-folder-2 (mno.com)
wordpress-files-folder
index.php
.htaccess
wordpress-site-folder-3 (qrst.com)
So in my example, the path to the actual wp-chron.php would be
public_html/wordpress-site-folder/wordpress-files-folder/wp-chron.php
But you are saying that the chron job path should go to the site root…
public_html/wordpress-site-folder/wp-chron.php
Yes? I just want to be sure to get it right!
Thanks!!
Your wp-cron.php file is directly inside the WordPress directory for each site, in which there would not be a separate folder inside it with additional WordPress files unless you have some sort of additional custom setup. If you take a look inside each WordPress installation, you will see a file named wp-cron.php. This is the file that needs to be referenced in the cron job for each site.
Thanks Jeff!
One further question… If I have a site in a folder and I run “WordPress in a folder” do I want the chron to be set to the root of that site i.e. … public_html/xyz or should I set the chron to the actual location of the wp-chron.php file i.e. … public_html/xyz/abc
The cron should run the wp-cron.php file inside the folder of that specific site. For example, if you have wordpress installed inside a folder names wordpress, you would set the cron to the following:
cd /home/userna5/public_html/wordpress; php -q wp-cron.php
I have a number of WordPress sites on my IMH account. Is this a “one size fits all” sort of thing? i.e. Will this make all my sites run a chron job at the same time? Most of my sites are in folders (like public_html/qrs/wordpress2, public_html/xyz/wordpress3, etc ) Is that a problem in any way?
This change will only affect the WordPress site that you make the change on and will not affect all other WordPress sites. You will need to make the change on each site if you want it active on all of them.
this tip helps a lot with dealing a monster site.
thanks.
No problem at all laishaoyi, glad it helped out!