How to set up a cron job in cPanel

Schedule a script to run automatically in cPanel, write the command correctly, stop the email flood, and replace WordPress’s unreliable wp-cron with a real one.

2–3 minutes

A cron jobCron job A task the server runs by itself on a timetable, like an alarm clock for jobs. For example, making a backup every night at 3 a.m. More about Cron job → runs a command on a schedule: every five minutes, every night, every Monday. Websites use them for backups, newsletters, imports and housekeeping. cPanel’s Cron Jobs tool sets them up without the command line.

Open Advanced » Cron Jobs, choose a schedule from Common Settings, enter the command, using full paths such as /usr/local/bin/php /home/user/public_html/script.php, and click Add New Cron Job. Add >/dev/null 2>&1 to the end to stop an email being sent every time it runs.

Add a cron job

cPanel Add New Cron Job form with Common Settings set to Once Per Day, the minute field, the command field and Add New Cron Job button highlighted
Advanced » Cron Jobs.
  1. Common Settings fills in the schedule for you, such as Once Per Day or Twice Per Hour.
  2. Or set Minute, Hour, Day, Month and Weekday yourself. * means “every”.
  3. Command: what to run (details below).
  4. Click Add New Cron Job.
cPanel Current Cron Jobs table showing the new job running at minute 0, hour 0 every day
The job appears under Current Cron Jobs, with Edit and Delete.

Times use the server’s time zone, which may differ from yours. The page’s examples and the server clock show which it uses.

Writing the command

Cron runs with almost no settings, so use full paths for everything:

/usr/local/bin/php /home/exampleco/public_html/wp-cron.php >/dev/null 2>&1
PartMeaning
/usr/local/bin/phpThe PHP program. The page shows the right path for your server
/home/exampleco/public_html/wp-cron.phpThe script, by its full path (your home directory is on the cPanel home screen)
>/dev/null 2>&1Throw away the output, so no email is sent

For a specific PHP version, use its own path, such as /usr/local/bin/ea-php83, as the page’s examples show.

To call a web address instead of a file, use curl:

/usr/bin/curl -s https://example.com/tasks/run >/dev/null 2>&1

Cron email

By default, cron emails any output to the address under Cron Email at the top of the page. That is useful while testing, and a flood once a job runs every five minutes. Either remove the output with >/dev/null 2>&1, or keep a log instead:

/usr/local/bin/php /home/exampleco/jobs/import.php >> /home/exampleco/logs/import.log 2>&1

WordPress: replace wp-cron

WordPress runs its scheduled tasks, such as publishing scheduled posts, sending emails and running backups, only when someone visits the site. On quiet sites tasks run late; on busy ones it adds work to page loads. Replace it with a real cron job:

  1. Add to wp-config.php, above That’s all, stop editing:
define( 'DISABLE_WP_CRON', true );
  1. Add a cron job running every 5 or 15 minutes:
/usr/local/bin/php /home/exampleco/public_html/wp-cron.php >/dev/null 2>&1

WP Toolkit’s Take over wp-cron.php switch does both steps for you. See WordPress in cPanel.

If it does not run

  • Run the exact command in Terminal (under Advanced) if your host allows it, to see errors.
  • Temporarily remove >/dev/null 2>&1 so errors are emailed to you.
  • Check paths: the most common mistake is a relative path such as public_html/script.php.
  • Hosts may limit how often jobs can run. Every minute is often blocked; every 5 minutes is usually fine.

Official documentation

Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.