A cron job runs a command on a schedule you choose: a PHP script, WordPress wp-cron.php, or a small maintenance task. You add it in cPanel. You do not need SSH.
This article is for Beginner and Standard shared hosting. Open cPanel from the portal. Do not guess a hostname.
On a VPS you edit the server crontab yourself.
We already keep hourly backups of the account. Do not schedule a dump of the site or a database into public_html. Those files count toward disk and can be downloaded by anyone who guesses the name.
Open cPanel
- Sign in at the portal.
- Open the hosting service for the site.
- Click Log in to cPanel.
Add a cron job
- In the Advanced section, open Cron Jobs.
- Under Cron Email, set an address you read (a mailbox on this account is fine). cPanel mails whatever the command prints. Save if the page asks you to.
- Under Add New Cron Job, pick a Common Settings interval (for example Once Per Hour or Once Per Day). That fills the five schedule fields for you.
- In Command, enter the full command. For a PHP script on this account:
php /home/username/public_html/script.php
Replace username with the cPanel username in General Information on the home page. Replace the path with the real file. Confirm the file in the File Manager. An addon domain or subdomain uses that site's document root, not always public_html.
- Click Add New Cron Job.
Use php (not a guessed binary path). That follows the version you set in Select PHP Version. The website can use a different per-folder version. If a scheduled script needs a specific version, set the account version first, or open a support ticket.
To stop email for a quiet job, append >/dev/null 2>&1 to the command. To keep a log outside the web root:
php /home/username/public_html/script.php >> /home/username/cron.log 2>&1
Do not write logs inside public_html.
Messages the job sends count toward the account's 1000 emails per hour. Split large sends, or open a support ticket if you need a different setup.
Custom schedule
If Common Settings does not match, set the five fields yourself. * means every value.
| Field | Values | Meaning |
|---|---|---|
| Minute | 0-59 | Minute of the hour |
| Hour | 0-23 | Hour of the day (24-hour clock) |
| Day | 1-31 | Day of the month |
| Month | 1-12 | Month |
| Weekday | 0-6 | Day of the week (0 is Sunday) |
Examples:
0 2 * * *at 02:00 every day*/15 * * * *every 15 minutes0 9 * * 1at 09:00 every Monday
Times follow the server clock. Shared hosting is in Australia. If a job ran at an unexpected hour, open a support ticket.
Do not run a job every minute unless the work is tiny and you have a reason. Frequent jobs count toward the account CPU, memory, and process limits. See Read your resource usage and metrics.
WordPress
WordPress runs scheduled work (publish later, plugin checks) when someone visits the site. That is unreliable on a quiet site and can slow a busy one.
- Add this line to
wp-config.php(above the "stop editing" comment) so visits stop triggering it:
define( 'DISABLE_WP_CRON', true );
- Add a cron job every 15 minutes:
cd /home/username/public_html && php wp-cron.php
Use that site's document root if WordPress is on an addon domain or in a subfolder. Prefer WordPress Toolkit or Installatron for the install itself. See Install WordPress.
Prefer the php command over hitting the site with wget or curl. The CLI path does not depend on DNS and does not use a web entry process.
Commands that must run over HTTP
Some older scripts only work when requested as a URL. Use https and send the body nowhere:
curl -s -o /dev/null "https://yourdomain.com/task.php"
Replace the URL with the real one. Protect that URL (a secret query string the script checks) so strangers cannot trigger it. If you are unsure how to lock it down, open a support ticket.
Change or remove a job
Scroll to Current Cron Jobs.
- Edit changes the schedule or command. Then click Update Cron Job.
- Delete removes the job.
If it does not run
- Confirm the file path in File Manager. It must start with
/home/username/. - Run a PHP script on the version you expect. See Choose your PHP version.
- Read the Cron Email, or the log file if you redirected output.
- Check Errors under Metrics if the same script also runs in the browser. See Fix a 500 Internal Server Error.
- Watch Resource Usage. A job that loops or runs too often can hit the plan limits.
If you still cannot tell why it failed, open a support ticket. Include the command, the schedule, and what you expected. We will look at the account with you.