How to Create a Cron Job in cPanel

Hosting Control Panel | Updated March 2026

Cron jobs let you run scripts automatically on a schedule, whether it's every five minutes or once a month. Ultra Web Hosting supports cron jobs on all shared, reseller, VPS, and dedicated hosting plans through cPanel's built-in cron manager. This guide covers everything from creating your first cron job to understanding the timing syntax.

01. What Is a Cron Job

A cron job is a scheduled task that runs a command or script at a specified time interval. The cron daemon runs in the background on the server and checks every minute whether any scheduled jobs need to execute. Common uses include:

Automated backups - Run a database dump or file backup script nightly.

Email processing - Check a mailbox or send queued emails on a schedule.

Data cleanup - Delete expired sessions, temporary files, or old logs.

WordPress maintenance - Replace WordPress's unreliable built-in cron with a real system cron.

Report generation - Generate daily or weekly reports from your database.

02. Creating a Cron Job in cPanel

  1. Log in to cPanel - Go to my.ultrawebhosting.com and open cPanel for your hosting package
  2. Open Cron Jobs - Under the "Advanced" section, click "Cron Jobs"
  3. Set the schedule - Use the "Common Settings" dropdown for preset intervals, or fill in the five time fields manually (minute, hour, day, month, weekday)
  4. Enter the command - Type the full command to run, for example: /usr/local/bin/php /home/username/public_html/cron_script.php >/dev/null 2>&1
  5. Click "Add New Cron Job" - The job is active immediately
Tip

Always add >/dev/null 2>&1 to the end of your command unless you specifically want to receive email output from every run. See our guide on controlling cron job emails for more options.

03. Understanding Cron Timing Syntax

Cron uses five fields to define the schedule. Each field accepts a number, a range, a list, or an asterisk (meaning "every"):

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

Special characters:

* (asterisk) - Matches every value. * * * * * runs every minute.

, (comma) - Lists multiple values. 0,15,30,45 in the minute field runs at those four minutes.

- (hyphen) - Defines a range. 9-17 in the hour field means 9 AM through 5 PM.

/ (slash) - Defines a step. */5 in the minute field means every 5 minutes. */2 in the hour field means every 2 hours.

04. Common Schedules

Ready-to-Use Schedules

Every 5 minutes: */5 * * * *

Every 15 minutes: */15 * * * *

Every hour: 0 * * * *

Twice daily (6 AM and 6 PM): 0 6,18 * * *

Daily at midnight: 0 0 * * *

Daily at 3 AM: 0 3 * * *

Weekly (Sunday at midnight): 0 0 * * 0

Monthly (1st at midnight): 0 0 1 * *

Important

Cron times use the server's timezone, which is set to US Central (CST/CDT) on Ultra Web Hosting shared servers. Keep this in mind when scheduling jobs that need to run at specific times in your local timezone.

05. PHP Cron Commands

There are two ways to run a PHP script via cron. The recommended method is to call the PHP binary directly:

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

The alternative is to use wget or curl to request the script via HTTP:

/usr/bin/curl -s https://yourdomain.com/cron_script.php >/dev/null 2>&1

Which should you use? The PHP binary method is preferred because it runs the script directly on the server without HTTP overhead, doesn't count against your bandwidth, isn't affected by web server timeouts, and can access files outside of public_html. Use the curl/wget method only when the script specifically needs to run in a web context (sessions, cookies, web-only includes).

Specifying a PHP Version

If your script requires a specific PHP version that differs from your account default, use the version-specific binary path:

# PHP 8.1
/usr/local/bin/ea-php81 /home/username/public_html/script.php

# PHP 8.2
/usr/local/bin/ea-php82 /home/username/public_html/script.php

# PHP 8.3
/usr/local/bin/ea-php83 /home/username/public_html/script.php

See our PHP version guide for more information on available versions.

06. WordPress Cron Setup

WordPress has a built-in task scheduler called WP-Cron, but it only runs when someone visits your site. For sites with low traffic, scheduled tasks like publishing posts, checking updates, and sending emails can be delayed significantly. Replacing WP-Cron with a real system cron fixes this.

  1. Disable WP-Cron - Add this line to your wp-config.php file, above the line that says "That's all, stop editing":
    define('DISABLE_WP_CRON', true);
  2. Create a system cron job - In cPanel, add a cron job running every 5 minutes:
    */5 * * * * /usr/local/bin/php /home/username/public_html/wp-cron.php >/dev/null 2>&1
Tip

Every 5 minutes is a good default for most WordPress sites. If your site doesn't need frequent scheduled task processing, every 15 minutes (*/15 * * * *) is fine and uses fewer server resources. For more WordPress optimization tips, see our WordPress performance guide.

07. Managing and Editing Cron Jobs

All your existing cron jobs are listed at the bottom of the Cron Jobs page in cPanel under "Current Cron Jobs." From there you can:

Edit a job - Click the pencil icon to modify the schedule or command. Click "Edit Line" to save.

Delete a job - Click the X icon to remove the cron job entirely. This takes effect immediately.

Change cron email - Update the "Cron Email" field at the top of the page to change where output emails are sent, or leave it blank to suppress all cron emails.

08. Troubleshooting

Cron Job Not Running

Verify the full path to both the PHP binary and your script. Relative paths don't work in cron because it runs without a working directory context. Use which php via SSH to confirm the PHP path, and check your home directory with echo $HOME.

Permission Denied

The script must be readable by your cPanel user. Check permissions with ls -la /home/username/public_html/script.php and ensure the file is at least 644 (chmod 644 script.php).

Script Works in Browser But Not in Cron

When PHP runs via cron, it uses the CLI (command line) SAPI, not the web SAPI. This means $_SERVER, $_GET, $_POST, and session variables are not available. Your script needs to work without these. Also, the working directory in cron is your home directory, not the script's directory. Use absolute paths for all file includes and requires.

Getting Blank Emails

If you're receiving empty cron emails, your script is probably outputting whitespace (blank lines, spaces) or your PHP file has a blank line after the closing ?> tag. Remove the closing ?> tag from PHP files used in cron, which is the recommended practice anyway.

Need Help Setting Up a Cron Job?

If you're not sure about the right command syntax or schedule for your specific task, our support team can help you set it up.

Open a Support Ticket

Quick Recap: Cron Jobs in cPanel

  1. Use full paths - Both the PHP binary (/usr/local/bin/php) and your script path must be absolute
  2. Suppress output - Add >/dev/null 2>&1 unless you want email notifications
  3. WordPress sites - Disable WP-Cron and use a system cron running every 5 minutes
  4. Server timezone - Cron uses US Central time (CST/CDT) on shared servers
  5. Test first - Run your command via SSH before adding it as a cron job to make sure it works

Last updated March 2026 · Browse all Hosting Control Panel articles

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

Invalid Syntax Error When Loading cPanel

Hosting Control Panel | Updated March 2026 An "Invalid Syntax Error" when loading cPanel...

What is bandwidth?

Hosting Control Panel | Updated March 2026 Bandwidth (also called data transfer) is the total...

How to Back Up Your Website

Hosting Control Panel | Updated March 2026 Backups are the single most important thing you...

I am unable to login to my hosting control panel any longer

Hosting Control Panel | Updated 2026 If you cannot log into cPanel, the issue is usually an...

How do I access the Control Panel?

Article Updated This article has been consolidated This guide has been merged into our...



Save 30% on web hosting - Use coupon code Hosting30