Skip to content
HOSTIGAN
cPanel

How to create cron jobs in cPanel

Run scripts on a schedule without editing a crontab. Learn cron syntax, create jobs in cPanel, find the PHP path and replace WP-Cron in WordPress.

Intermediate 6 min read Updated November 24, 2026

Some tasks need to happen on their own: send a newsletter every night, import stock levels each hour, clean out old sessions once a week or run WordPress's scheduled tasks on time. On Linux this is the job of cron, and cPanel gives you a form for it, so you never have to edit a crontab file by hand.

By the end of this guide you will be able to read and write a cron schedule, create a job in cPanel, call PHP with the right path, keep your inbox from filling with cron mail, and stop two runs of the same job from colliding.

How cron works

The cron service on the server wakes up every minute and checks whether any job is due. When one is, it runs the command as your cPanel user, within your account's limits and without any browser involved. A job has four parts:

  • A schedule — when it runs.
  • A command — what it runs: a PHP script, a shell script, or curl/wget fetching a URL.
  • A user — your account, with your permissions.
  • Output — whatever the command prints, which cron emails to you unless you redirect it.

Read and write cron syntax

A schedule is five fields separated by spaces:

┌──────── minute (0–59)
│ ┌────── hour (0–23)
│ │ ┌──── day of month (1–31)
│ │ │ ┌── month (1–12)
│ │ │ │ ┌ weekday (0–6, 0 = Sunday)
│ │ │ │ │
* * * * *  command

The symbols you will use most:

SymbolMeaningExample
*Every value* in hour = every hour
*/nEvery n units*/15 in minute = every 15 minutes
,A list1,15 in day = the 1st and 15th
-A range1-5 in weekday = Monday to Friday

Some real schedules:

ScheduleRuns
*/5 * * * *Every five minutes
17 * * * *Every hour at :17
43 3 * * *Every night at 03:43
30 6 * * 1Mondays at 06:30
0 2 1 * *The 1st of every month at 02:00

Tip: Avoid running nightly jobs at exactly 0 0 or 0 3. Everyone else does, and the server is busiest on the hour. An odd minute like 17 or 43 spreads the load.

Remember that times follow the server's clock. If the server runs on UTC and you are in Central Europe, 0 6 * * * fires at 07:00 or 08:00 your time, depending on daylight saving.

Create a cron job in cPanel

  1. Open Advanced › Cron Jobs, or search for "cron".
  2. Under Cron Email, enter an address and click Update Email. While you are testing, you want to see what the job prints.
  3. Under Add New Cron Job, pick an interval from Common Settings, or fill in Minute, Hour, Day, Month and Weekday yourself.
  4. In Command, enter the full command (examples below).
  5. Click Add New Cron Job.

The job is listed under Current Cron Jobs, where you can Edit or Delete it. When testing, set a new job to every minute, check the result, then change it to the real schedule.

Run PHP scripts the right way

Cron runs with a minimal environment, so always use full paths — both to PHP and to the script:

/usr/local/bin/php -q /home/USERNAME/scripts/import.php

-q suppresses the HTTP headers PHP would otherwise print. The command-line PHP version is not always the same as the version your website uses. If you have Terminal in cPanel (or SSH access), check what you get:

which php
php -v
ls /opt/cpanel/ | grep ea-php

The last line lists the PHP versions installed through cPanel's EasyApache. To pin a version, call its binary directly, for example /opt/cpanel/ea-php83/root/usr/bin/php. Without Terminal, make a temporary cron job that runs /usr/local/bin/php -v and read the answer in the cron email.

PHP CLI or curl?

PHP CLIcurl / wget to a URL
Web server time limitsNot affectedCan time out
Can be triggered by outsidersNoYes, if the URL is public
Uses the site's PHP settingsNot necessarilyYes
Good forYour own scripts on the accountTriggering external services or apps that only expose a URL

Use PHP CLI for scripts that live on your hosting. A URL-based job looks like this:

/usr/bin/curl -fsS "https://www.example.com/cron.php?key=LONG_RANDOM_KEY" > /dev/null

Control the output

By default every line a job prints lands in your inbox. A job running every five minutes means 288 emails a day. Once it works, pick one of these patterns:

Discard all output:

/usr/local/bin/php -q /home/USERNAME/scripts/job.php > /dev/null 2>&1

Append everything to a log file:

/usr/local/bin/php -q /home/USERNAME/scripts/job.php >> /home/USERNAME/logs/job.log 2>&1

Discard normal output, but still get errors by email:

/usr/local/bin/php -q /home/USERNAME/scripts/job.php > /dev/null

Keep logs outside public_html so nobody can download them, and empty or rotate them now and then so they don't eat your disk quota.

Note: In a crontab, % means "new line". If your command contains one, for example in date +%F, escape it as \%.

Replace WP-Cron in WordPress

WordPress has its own pseudo-cron that only runs when someone visits the site. On quiet sites, scheduled posts and emails are late; on busy ones it runs far more often than needed. A real cron job fixes both.

  1. Open wp-config.php in File Manager and add this line above /* That's all, stop editing! */:
define( 'DISABLE_WP_CRON', true );
  1. Create a cron job that runs every five minutes:
cd /home/USERNAME/public_html && /usr/local/bin/php -q wp-cron.php > /dev/null 2>&1
  1. Schedule a test post a few minutes ahead and check that it publishes on time.

Several WordPress sites on one account each need their own job — stagger them on different minutes. It is one of the simplest wins in our guide to making WordPress faster.

Stop jobs from overlapping

If an import takes seven minutes and runs every five, two copies end up working at once: duplicate emails, locked tables, doubled load. flock prevents this by taking a lock file. If the lock is held, the new run quietly exits:

/usr/bin/flock -n /home/USERNAME/tmp/import.lock /usr/local/bin/php -q /home/USERNAME/scripts/import.php > /dev/null 2>&1

The lock is released automatically when the script ends, even if it crashes.

Keep cron jobs light and safe

Cron jobs share CPU, memory and process limits with your website. A heavy job at the wrong time can slow the site down or cause resource errors. Sensible intervals:

  • Every 5–15 minutes: queues, WP-Cron, small syncs.
  • Hourly or daily: reports, imports, clean-up.
  • Every minute: only very light checks.

On permissions: PHP scripts called through the interpreter only need to be readable (644). Shell scripts you execute directly need 700 or 755. Never use 777. Our PHP performance guide has more on what eats resources on shared hosting.

Common errors and fixes

ErrorCause and fix
Could not open input fileWrong or relative script path — use the full path from /home/USERNAME/
command not foundCron's PATH is minimal — use the full path, find it with which
Permission deniedCall the script through its interpreter, or fix its permissions
Runs but does nothingRelative include paths break because cron starts in your home folder — cd first, or use __DIR__ in PHP
Nothing happens at allCheck the schedule against the server's time zone, and look for typos in the five fields

When a job writes to a database, take a backup before you let it loose; see how to back up in cPanel. If you are new to the command line, our essential Linux commands guide explains cd, paths and permissions.

In short

  • Create jobs under Advanced › Cron Jobs, and test with Cron Email before silencing output.
  • Write five fields, remember the server's time zone, and use odd minutes.
  • Always use full paths, and prefer PHP CLI for your own scripts.
  • Replace WP-Cron with a real job using DISABLE_WP_CRON.
  • Wrap long jobs in flock so they never overlap.

Cron jobs on Hostigan hosting

Hostigan web hosting comes with cPanel, so you can schedule jobs exactly as described here, and our WordPress hosting is a good fit if most of your scheduled work is WordPress.

Frequently asked questions

They run in the server's time zone, not your own or your website's. Check it with a test job that runs the date command and emails you the result.

Next in “Your hosting in production” · 8 of 11How to back up your website and database in cPanel