Setting up a cron job

A cron job runs a command on a schedule. In cPanel, open Cron Jobs.

The schedule

Five fields: minute, hour, day of month, month, day of week. cPanel provides common settings from a dropdown, which is easier than writing them by hand. A few examples:

  • */15 * * * * – every fifteen minutes
  • 0 * * * * – once an hour, on the hour
  • 30 2 * * * – once a day at 2:30am

The command

Use a full path to the PHP binary and a full path to the script:

/usr/local/bin/php /home/username/public_html/script.php

Not the web address, and not a relative path. A relative path is the most common reason a cron job silently does nothing.

Where the output goes

By default anything the script prints is emailed to you, every time it runs. For a job running every fifteen minutes that is a great deal of mail. To discard normal output but still be told about errors, end the command with >/dev/null. To discard everything, use >/dev/null 2>&1 – but then you will not hear about failures either.

Common mistakes

  • Scheduling something heavy every minute. Ask whether it genuinely needs to be that often.
  • Assuming cron runs as the web server. It runs as you, so file permissions can differ.
  • Expecting the same PHP version as the website – specify the binary you want.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

cPanel Disk Usage Warning

If you are running low on disk space you may receive an automatic warning from our cPanel Hosting...

I dont know what my cPanel account password is

If you have forgotten the login or password details used to access your cPanel control panel or...

How do I change my cPanel password

If you want to change the cPanel password, then this can be done by logging into your secure...

Reseller Guide: Branding cPanel as Your Own

What you can brand as a reseller As a reseller you can present cPanel to your customers under...