Skip to content
0850 554 5439 [email protected]

What do you need help with?

Search the guides and tutorials, or browse the categories.

cPanel Cron Jobs: replace WordPress wp-cron with a real cron job and schedule a PHP script

Shared Hosting 40 views Step-by-step guide Last verified: Markdown
What you will learnHow to stop WordPress scheduled tasks from depending on visitors by running them regularly with cPanel Cron Jobs, how to run your own PHP file at a set time, and how to manage cron emails.
Time10 minutes

1. What is wp-cron, and why replace it?

WordPress uses the wp-cron.php file to publish scheduled posts, check for updates, and run backup plugins and WooCommerce emails. By default this file is triggered when a visitor opens a page. As a result:

  • Tasks run late, or not at all, in hours with few visitors.
  • At busy times, every page view needlessly checks for tasks.

The fix is to run wp-cron.php from a cron job in cPanel at a regular interval and turn off WordPress's own trigger. The order matters: add the cron job first, then turn off the WordPress trigger.

The tool is in the Advanced section of the cPanel home page.

Open Cron Jobs in the Advanced section of the cPanel home page.

2. Step 1: Add a cron job for wp-cron

  1. Open Cron Jobs in the Advanced section.
  2. Scroll down to Add New Cron Job.
  3. Enter */15 in Minute, or choose Once Per Fifteen Minutes in the list next to it. Leave * in Hour, Day, Month and Weekday. This means the job runs every 15 minutes.
  4. Enter the following in Command, replacing username with your cPanel username:

cd /home/username/public_html && /usr/local/bin/php -q wp-cron.php >/dev/null 2>&1

  1. Click Add New Cron Job.
Enter */15 for minute and * for the other fields, enter the wp-cron.php command and click Add New Cron Job.
  1. The job appears in the Current Cron Jobs table at the bottom of the page. You can change it with Edit or remove it with Delete.
The new job appears in Current Cron Jobs, where you can edit or delete it.
Info

If WordPress is installed in a subdirectory or on an addon domain, use that site's folder instead of public_html (e.g. /home/username/public_html/blog or /home/username/yourdomain.com). The right folder is the one containing wp-config.php; you can check it in File Manager.

The >/dev/null 2>&1 at the end discards the job's output, so you don't get an email every 15 minutes.

3. Step 2: Turn off WordPress's own trigger

If the site was installed with Softaculous:

  1. In cPanel, open WordPress Manager by Softaculous and open your site's row.
  2. Under Configuration, set WordPress Cron (wp-cron.php) to Disabled.
After setting up a real cron job, set WordPress Cron (wp-cron.php) to Disabled in WordPress Manager.

If the site wasn't installed with Softaculous, open wp-config.php in File Manager and add this line above /* That's all, stop editing! */:

define( 'DISABLE_WP_CRON', true );

Warning

If you turn off the trigger and forget the cron job, no scheduled task runs: scheduled posts aren't published and WooCommerce emails aren't sent. Check that the job appears in Current Cron Jobs.

4. Check that it works

  1. Wait 15–20 minutes.
  2. In the WordPress dashboard, check Tools → Site Health for any warning about scheduled events.
  3. If you use WooCommerce, check WooCommerce → Status → Scheduled Actions: no past-due jobs should pile up on the Pending tab.
  4. You can also test with a draft post scheduled a few minutes ahead: it should be published on time.

5. Schedule your own PHP file

To run a report, clean-up or sync file at a set time:

  1. Choose the time under Add New Cron Job. For example, for every day at 03:00: Minute 0, Hour 3, the others *.
  2. In Command, enter the PHP path and the full path of the file:

/usr/local/bin/php /home/username/public_html/araclar/gunluk-rapor.php

  1. Click Add New Cron Job.
For your own PHP script, enter the PHP path and the full file path; set the time with the minute and hour fields.
Info

/usr/local/bin/php uses the server's default PHP version. If your file must run with the version assigned to your domain in MultiPHP Manager, use the ea-php path as shown in the example on the page; for PHP 8.3 that is /usr/local/bin/ea-php83 (B34).

Warning

Put files that should only run from cron somewhere they can't be opened from the web, for example /home/username/araclar/ outside public_html. Anyone can run a file inside public_html from a browser.

6. Manage cron emails

A cron job that produces output sends the result to the address in the Cron Email section every time it runs.

  1. In Cron Email, enter your address in Email and click Update Email.
  2. When you first add a new job, leave out >/dev/null 2>&1; the email tells you whether the job works. Once you're sure, add it to stop the emails.
Output from cron jobs that print something is emailed to the address in Cron Email.

7. Common problems

Symptom Cause Fix
"Could not open input file" email Wrong file path Check the full path in File Manager and fix the command.
Scheduled posts aren't published The trigger was turned off but there's no cron job, or it points to the wrong folder Add the cron job; make sure cd goes to the folder containing wp-config.php.
An email arrives on every run The command produces output Add >/dev/null 2>&1 to the end of the command.
PHP version error ("syntax error", "requires PHP 8") The default PHP version is too old for your file Use the ea-php path (e.g. /usr/local/bin/ea-php83).
The site slowed down A heavy job runs too often Run it less often (e.g. hourly instead of every 15 minutes) or move it to night time.

8. FAQ

How often should the cron job run?

Every 15 minutes is enough for wp-cron on most sites. Running it every minute is usually unnecessary and wastes your account's resources.

I have several WordPress sites. Do I need a job for each?

Yes. Add a separate cron job for each site pointing to its own folder, and turn off WordPress Cron on each.

Which time zone does the cron schedule use?

Cron jobs run on the server's clock. If the exact hour matters, confirm the first run time from the email.

Can I set up cron by calling the URL with wget or curl?

You can, but running the PHP file directly is more reliable because it doesn't depend on the site's cache, firewall or SSL certificate.

How do I pause a cron job?

Remove it with Delete in Current Cron Jobs. If you turned off WordPress's wp-cron, remember to set WordPress Cron back to Enabled when you delete the job.

Did you know?

On Gyro hosting plans you add cron jobs yourself in cPanel, so you can run scheduled backup, report or clean-up files without any extra server access.

Next step

  • B38: Hosting settings and security checklist for a WooCommerce store
  • B34: Changing the PHP version and PHP settings
  • B33: Speeding up your WordPress site
Was this helpful?

Thanks for your feedback!

Still Need Help?

The support team is here around the clock for anything you can't find in the knowledge base.