A cron job runs a command automatically on a schedule.
CREATING ONE
- In cPanel open Cron Jobs under Advanced.
- Enter an email address at the top to receive the output, or leave it blank to avoid a flood of messages.
- Pick an interval under Common Settings, or set the five fields manually (minute, hour, day, month, weekday).
- Enter the command.
- Click Add New Cron Job.
COMMON COMMANDS
Run a PHP file:
/usr/local/bin/php -q /home/USERNAME/public_html/script.php >/dev/null 2>&1Run a WordPress cron (required on our servers, where HTTP wp-cron is blocked):
/usr/local/bin/php -q /home/USERNAME/public_html/wp-cron.php >/dev/null 2>&1Replace USERNAME with your cPanel username. The >/dev/null 2>&1 part discards output so you are not emailed on every run.
GUIDELINES
Do not schedule anything every minute unless it is genuinely required. Every 5 or 15 minutes is almost always enough, and frequent jobs consume your CPU allowance. Test the command once by hand, or temporarily set an email address, to confirm it works before leaving it unattended. Delete cron jobs for software you have removed. Orphaned jobs generate errors and waste resources.