How to Set Up a Cron Job in cPanel

A cron job runs a command or script on a schedule, such as every hour or once a night, without you having to do anything. This guide shows how to set up a cron job in cPanel on an Instant Access Internet Services account, with ready-to-use command examples for PHP scripts and WordPress, and how to control the emails cron sends you.

How to add a cron job in cPanel

  1. Log in to cPanel and go to Advanced > Cron Jobs.
  2. Scroll to Add New Cron Job.
  3. Pick a schedule from the Common Settings menu (for example Once Per Hour or Once Per Day). This fills in the Minute, Hour, Day, Month and Weekday boxes for you. You can also type your own values.
  4. In Command, enter the command to run (see the examples below).
  5. Click Add New Cron Job. It appears in the Current Cron Jobs list at the bottom of the page, where you can Edit or Delete it later.

Cron times use the server's clock, which may not match your time zone. If the exact hour matters, run a test job and check the time on the email it sends.

Understanding the schedule fields

MinuteHourDayMonthWeekdayRuns
*/15****Every 15 minutes
0****At the start of every hour
302***Every day at 2:30 am
06**1Every Monday at 6:00 am
001**Midnight on the 1st of each month

A * means "every". Weekday 0 is Sunday, 1 is Monday, and so on. Please don't run jobs more often than they need to: if a job is still running when the next one starts, they pile up and can slow your site or hit your account's resource limits. Every 5 or 15 minutes is plenty for most tasks.

Example cron commands

Replace username with your cPanel username, shown in the General Information panel on the cPanel home page.

Run a PHP script

/usr/local/bin/php /home/username/public_html/scripts/task.php

/usr/local/bin/php runs the server's default PHP, currently PHP 8.2. It does not follow the version you picked for your website in MultiPHP Manager. Always use the full path to the script.

Run a script with a specific PHP version

If your site uses a different version (check Software > MultiPHP Manager), use that version's full path so the cron job matches your website:

PHP versionPath to use in the command
8.2 (default)/usr/local/bin/php
8.1/opt/cpanel/ea-php81/root/usr/bin/php
7.4/opt/cpanel/ea-php74/root/usr/bin/php
Other versions/opt/cpanel/ea-phpXX/root/usr/bin/php, where XX is the version without the dot (for example 83 for PHP 8.3)
/opt/cpanel/ea-php81/root/usr/bin/php /home/username/public_html/scripts/task.php

Run a PHP script quietly (no emails)

/usr/local/bin/php /home/username/public_html/scripts/task.php >/dev/null 2>&1

Call a web address

curl -s https://example.com/cron.php >/dev/null 2>&1

Run a shell script

/bin/bash /home/username/scripts/cleanup.sh

Replacing WordPress's built-in cron (WP-Cron)

WordPress normally runs its scheduled tasks (publishing scheduled posts, sending plugin emails, backups) when someone visits the site. On a quiet site tasks can run late, and on a busy site it adds extra work to page loads. A real cron job fixes both.

  1. In Files > File Manager, edit wp-config.php and add this line above /* That's all, stop editing! */:
    define( 'DISABLE_WP_CRON', true );
  2. In Advanced > Cron Jobs, add a job every 15 minutes (Minute */15, all other fields *) with this command:
    cd /home/username/public_html && /usr/local/bin/php wp-cron.php >/dev/null 2>&1

If WordPress is installed in a subfolder, change the path to match. If your site doesn't run PHP 8.2, replace /usr/local/bin/php with the path for your version from the table above.

How to control cron emails

By default, cron emails you whatever a job prints each time it runs. For a job every 15 minutes, that's almost 100 emails a day.

  • To change where the emails go, enter an address in the Cron Email section at the top of the page and click Update Email.
  • To silence one job, add >/dev/null 2>&1 to the end of its command.
  • While you set up a new job, leave the output on so you can see any errors, then add the redirect once it's working.

Troubleshooting

My cron job doesn't seem to run

Remove >/dev/null 2>&1 temporarily and set a cron email address so you can read the output. "No such file or directory" means a path is wrong; "Permission denied" usually means a shell script isn't executable (set it to 755 in File Manager) or should be run with /bin/bash in front.

The script works in the browser but not from cron

Scripts run from cron don't start in your website folder. Use full paths everywhere, or start the command with cd /home/username/public_html && as in the WordPress example.

Is there a limit on how often cron can run?

Very frequent jobs (every minute) use a lot of your account's CPU allowance. If you need something to run more often than every 5 minutes, open a ticket first so we can suggest a better approach.

Related guides

Still stuck? Open a support ticket and the Instant Access Internet Services team will help.

Ultrafast LiteSpeed hosting from InstantAccess.net: free SSL, free backups, cPanel included, no contracts. Check out our $10/month hosting.
  • cpanel cron job, how to set up cron job, cron job every 5 minutes, wordpress cron cpanel, disable wp-cron, cron job php command
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Change Your PHP Version in cPanel

Running a current PHP version keeps your website faster and more secure, and many WordPress...

How to Change PHP Settings (memory_limit, upload_max_filesize)

If WordPress says "The uploaded file exceeds the upload_max_filesize directive", a plugin runs...

How to Check Your Website Error Log and Recent Visitors

When your website shows a blank page, a "500 Internal Server Error" or a feature just stops...

How to View Website Statistics with AWStats and Bandwidth

Your Instant Access Internet Services hosting account includes built-in website statistics, so...

How to Use SSH, SSH Keys and Terminal in cPanel

SSH gives you a command line on your Instant Access Internet Services hosting account, which is...