How to Set Up Cron Jobs in cPanel (with Practical Examples)

How to Set Up Cron Jobs in cPanel (with Practical Examples)

A cron job is a task that your server runs automatically on a schedule, such as every hour, every night or once a week. cPanel makes it easy to create cron jobs without using the command line. In this guide, you will learn how cron timing works, how to add a cron job in cPanel, and how to use practical examples like replacing WordPress wp-cron, running PHP scripts and silencing email output.

What can you do with cron jobs?

Cron jobs are useful whenever something needs to happen regularly without you remembering to do it. Common uses include:

  • Running WordPress scheduled tasks reliably, such as publishing scheduled posts and sending emails
  • Running a PHP script that sends daily reports or clears old records
  • Fetching a URL to trigger a task in a web application
  • Cleaning up temporary or cache files
  • Running scheduled tasks required by billing, CRM or e-commerce software

Understanding cron syntax

Every cron job has a schedule made of five fields, followed by the command to run:

*  *  *  *  *  command-to-run
|  |  |  |  |
|  |  |  |  +---- Weekday (0-6, Sunday = 0)
|  |  |  +------- Month (1-12)
|  |  +---------- Day of month (1-31)
|  +------------- Hour (0-23)
+---------------- Minute (0-59)

An asterisk * means “every”. You can also use */15 for “every 15”, commas for lists like 1,15, and hyphens for ranges like 1-5.

ScheduleMinuteHourDayMonthWeekday
Every 15 minutes*/15****
Every hour, on the hour0****
Twice a day (midnight and noon)00,12***
Every day at 2:30 AM302***
Every Monday at 9:00 AM09**1
Weekdays at 6:00 PM018**1-5
1st of every month at midnight001**

Tip: Cron runs in the server’s time zone, which may not be Indian Standard Time. If your server is set to UTC, 2:30 AM UTC is 8:00 AM IST. Ask your host or check the server time before scheduling time-sensitive jobs.

How to add a cron job in cPanel

  1. Log in to cPanel.
  2. Go to the Advanced section and click Cron Jobs, or search for “Cron Jobs” at the top.
  3. Optionally, enter an address in the Cron Email box and click Update Email. Output from your cron jobs will be sent there.
  4. Under Add New Cron Job, open the Common Settings drop-down and pick a schedule such as Once Per Hour or Once Per Day. This fills in the five time fields for you. You can also edit the fields manually.
  5. In the Command box, enter the command you want to run, using full paths.
  6. Click Add New Cron Job. It now appears under Current Cron Jobs, where you can Edit or Delete it.

The Common Settings drop-down includes options such as Once Per Minute, Once Per Five Minutes, Twice Per Hour, Once Per Hour, Twice Per Day, Once Per Day, Once Per Week, On the 1st and 15th of the Month, Once Per Month and Once Per Year. Many shared hosts do not allow jobs more often than every 5 or 15 minutes, so check your provider’s policy before choosing a very frequent schedule.

Finding the correct PHP path

Cron does not always know where programs are, so you should use the full path to PHP. On most cPanel servers with EasyApache 4, these paths work:

  • /usr/local/bin/php: a wrapper that normally uses the PHP version set for your domain in MultiPHP Manager.
  • /opt/cpanel/ea-php82/root/usr/bin/php: a specific PHP version (here 8.2). Change 82 to the version you need, such as 83.

If your server uses CloudLinux PHP Selector, the path may be different, for example under /opt/alt/. If you have Terminal access in cPanel, run which php and php -v to check. Otherwise, your host’s support team can confirm the right path.

Practical cron job examples

1. Replace WordPress wp-cron with a real cron job

By default, WordPress runs its scheduled tasks through wp-cron.php whenever someone visits your site. On low-traffic sites, tasks may be delayed; on busy sites, it adds extra load on every visit. A real cron job is more reliable.

First, open wp-config.php in File Manager and add this line above the line that says /* That's all, stop editing! */:

define( 'DISABLE_WP_CRON', true );

Then add a cron job set to every 15 minutes (*/15 * * * *) with this command:

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

If your WordPress is installed in a subfolder or addon domain folder, change the path accordingly.

2. Run a PHP script

To run a custom script every day at 1:00 AM (0 1 * * *):

/usr/local/bin/php /home/username/scripts/daily-report.php > /dev/null 2>&1

Keeping scripts outside public_html means visitors cannot run them from a browser.

3. Call a URL with curl or wget

Some applications give you a URL to trigger scheduled tasks. You can call it with curl:

curl -s https://yourdomain.com/cron.php?key=YOURSECRETKEY > /dev/null 2>&1

Or with wget:

wget -q -O /dev/null https://yourdomain.com/cron.php?key=YOURSECRETKEY

This method also works for WordPress, using https://yourdomain.com/wp-cron.php?doing_wp_cron, but running the file with PHP directly, as in example 1, avoids an extra web request.

4. Save output to a log file

Instead of discarding output, you can keep a log to check later:

/usr/local/bin/php /home/username/scripts/sync.php >> /home/username/logs/sync.log 2>&1

The >> adds to the log each time instead of overwriting it. Create the logs folder first, and clean the file occasionally so it does not grow too large.

Output redirection and email notifications

By default, any output from a cron job is emailed to the address in Cron Email. This is helpful while testing but quickly fills your inbox if a job runs every few minutes. Here is what the common redirections mean:

  • > /dev/null: discards normal output.
  • 2>&1: sends error output to the same place as normal output.
  • > /dev/null 2>&1 together: discards everything, so no email is sent.
  • > /dev/null alone: discards normal output but still emails you errors, which is a useful middle ground.

A good habit is to test a new cron job with email enabled, confirm it works, and then add > /dev/null 2>&1 or a log file.

Common problems and fixes

The cron job does not seem to run

  • Check that you used full paths for both PHP and your script.
  • Remove the redirection temporarily so errors are emailed to you.
  • Confirm the schedule is correct and remember the server time zone.

“Could not open input file”

The script path is wrong. Copy the exact path from File Manager, which shows the full path starting with /home/username/.

The script works in a browser but not in cron

Scripts that use relative paths may fail because cron runs from a different directory. Start your command with cd /home/username/public_html && or use absolute paths inside the script.

Resource limit warnings

Heavy jobs running too often can push your account over CPU or process limits. Reduce the frequency and schedule heavy tasks at night.

Frequently asked questions

How often can I run a cron job on shared hosting?

Technically, cron can run every minute, but many shared hosts set a minimum interval such as 5 or 15 minutes. Check your provider’s terms.

Can I run a cron job as a different user?

No. Cron jobs created in cPanel run as your cPanel user, with your account’s permissions and resource limits.

Will disabling wp-cron break my WordPress site?

Not if you add a real cron job to replace it. Without that replacement, scheduled posts and plugin tasks will stop running.

How do I stop receiving cron emails?

Add > /dev/null 2>&1 to the end of the command, or clear the Cron Email field.

Conclusion

Cron jobs in cPanel let you automate routine tasks with just a schedule and a command. Learn the five-field syntax, use full paths to PHP and your scripts, test with email output first, and then silence or log the output. Start by replacing WordPress wp-cron with a real cron job, and you will quickly see how useful scheduled automation can be.