Havenswift Hosting Ltd
All guides

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:

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

Other guides

Still stuck? Sign in and raise a ticket, and somebody will answer it.

Sign in