Help center · Domains and cPanel
How to schedule cron jobs in cPanel and run WordPress wp-cron
To schedule a task in cPanel, open Cron Jobs, choose the frequency, type the command with the absolute path to the file (for example, php /home/username/public_html/wp-cron.php), and click Add New Cron Job. cPanel runs the command on its own at the set time, without you needing to be logged in.
A cron job is a scheduled task: the server runs a command every hour, every day, or every 15 minutes. It’s used to clean up temporary files, generate reports, run PHP scripts and, most commonly on WordPress sites, reliably trigger WordPress’s own scheduled tasks. cPanel menu names change depending on the version and theme, so use the paths below as a reference.
How to create a cron job in cPanel
- Log in to cPanel.
- In the Advanced section, open Cron Jobs (in some versions, this item may have a different name).
- Under Common Settings, choose a ready-made frequency, such as “Every 15 Minutes” or “Once Per Day”. The minute, hour, day, month, and weekday fields are filled in for you.
- In the Command field, type the command to be run.
- Click Add New Cron Job.
- Check the result in the Current Cron Jobs list, further down the same screen.
If you prefer to build the schedule by hand, fill in the five time fields as explained below.
Schedule syntax
The schedule is made up of five fields, always in this order: minute, hour, day of the month, month, and day of the week. The asterisk (*) means “all”. The slash (*/15) means “every 15”.
| Expression | When it runs |
|---|---|
* * * * * |
Every minute |
*/5 * * * * |
Every 5 minutes |
*/15 * * * * |
Every 15 minutes |
0 * * * * |
At minute zero of every hour |
0 3 * * * |
Every day, at 3 a.m. |
30 8 * * 1 |
Every Monday, at 8:30 a.m. |
0 0 1 * * |
On the first day of every month, at midnight |
Days of the week run from 0 to 6, starting with Sunday. The schedule follows the server’s time zone, which may be different from yours, so check it before scheduling anything that has to run at an exact time. To find out the minimum frequency allowed on your plan, ask support through the contact page, since I can’t confirm that rule here.
Write the command with php and an absolute path
Cron doesn’t “see” the folder you’re in within File Manager. That’s why the command needs the absolute path, which starts with /home/ followed by your cPanel username:
/usr/local/bin/php /home/username/public_html/script.php
A few important points:
- Replace
usernamewith your cPanel username. Your account path appears in File Manager when you open the home folder. - The path to
phpis usually/usr/local/bin/php, but it can vary depending on the server configuration. If the command doesn’t run, ask support for the correct path. - The PHP version used by cron isn’t always the same one chosen for your site. If your script requires a specific version, confirm it. To understand PHP versions, see how to change the PHP version in cPanel.
- Quotes and spaces count: a typo makes cron fail silently.
Run WordPress wp-cron through a real cron job
WordPress has its own scheduled task system, wp-cron.php. It publishes scheduled posts, checks for updates, and runs plugin tasks. The problem is that, by default, it only runs when someone visits the site. On sites with little traffic, tasks get delayed. On sites with heavy traffic, it runs more often than necessary and puts load on the server.
The solution is to turn off the trigger on visits and call wp-cron.php through a real cron job:
- Using File Manager or FTP, open the
wp-config.phpfile in the WordPress folder. Before doing that, make a copy: see how to back up WordPress. - Above the line that says
/* That's all, stop editing! */(or similar text), add:
define('DISABLE_WP_CRON', true);
- Save the file.
- In Cron Jobs, create a task every 15 minutes (
*/15 * * * *) with this command:
/usr/local/bin/php /home/username/public_html/wp-cron.php >/dev/null 2>&1
If WordPress is in a subfolder, adjust the path, for example /home/username/public_html/blog/wp-cron.php. If there’s a typo in wp-config.php, the site may show a white screen; in that case, see 500 error or white screen in WordPress.
If your plan doesn’t allow running PHP directly from cron, one alternative is to call the site’s address with wget or curl, but the method using php and an absolute path is usually lighter.
How to avoid an email on every run
By default, cron emails the output of each run. A task every 15 minutes can generate almost 100 messages a day. There are two ways to solve this:
- Discard the output in the command itself. Add
>/dev/null 2>&1at the end, as in the example above. Nothing else is sent, not even errors. - Set an email address just for cron. At the top of the Cron Jobs screen, the email field lets you choose who receives the notifications. Use an address you actually read, and once cron is stable, go back to discarding the output.
During testing, keep email turned on so you can see the error messages. Only discard the output after everything is working.
How to check whether cron ran
- Cron with email on: a message arrives after the run, with the result of the command.
- Script that writes a file or record: check the file’s modification date in File Manager.
- WordPress: install a scheduled task management plugin, such as WP Crontrol, and check the upcoming runs and the time of the last one.
- Quick test: temporarily create a cron job that runs every minute, wait a few minutes, check the result, and then remove the task.
If nothing happens, check the absolute path, the path to php, and the file permissions. If the script sends email, also see WordPress isn’t sending contact form emails.
Frequently asked questions
What is the ideal frequency for wp-cron?
For most sites, every 15 minutes is enough. Sites with many scheduled posts or online stores may use shorter intervals. Confirm the minimum frequency allowed on your plan with support through the contact page.
Does cron run if I don’t visit the site?
Yes. That’s exactly the advantage: cron runs on the server at the scheduled time, with or without visits.
Can I schedule more than one cron job?
Yes. Each task is a line in the Current Cron Jobs list. The limit depends on your plan; if you’re unsure, ask support.
How do I delete or edit a cron job?
In the Current Cron Jobs list, use Edit to change the schedule or command, or Delete to remove the task.
I set DISABLE_WP_CRON and my scheduled posts aren’t publishing. What should I do?
The real cron job is probably not running. Check the path to wp-cron.php, the path to php, and the frequency. If you want to go back to the default behavior, remove the DISABLE_WP_CRON line from wp-config.php.
Does cron back up my site?
MigraCloud’s automatic backup is made with JetBackup, and you restore it yourself in cPanel. See backup in cPanel with JetBackup. For your own script-based backups, you can use cron, but keep the copies outside your hosting.