A cron job runs a command or script automatically on a schedule, for example every 15 minutes, every night at 2am, or once a week. Website software often needs one for tasks like sending queued emails, processing orders, clearing out old data or running scheduled posts.
Before you start
- Check your software's documentation for the exact command it needs. Most give you a ready-made line to copy.
- Find the full path to the script. Your home folder is
/home/yourusername/, whereyourusernameis your cPanel username (shown in cPanel under General Information). So a script in your main website folder is at/home/yourusername/public_html/script.php.
Add a cron job
- Log in to cPanel from your service page under Services → My Services (https://www.hooplahosting.co.nz/client/clientarea.php?action=services).
- Open Cron Jobs (type it in the cPanel search bar).
- Under Add New Cron Job, choose a schedule from the Common Settings drop-down, for example Once Per Hour or Twice Per Hour. This fills in the minute, hour, day, month and weekday boxes for you. You can also type your own values into those boxes.
- Paste your command into Command.
- Click Add New Cron Job.
Your cron job appears under Current Cron Jobs, where you can Edit or Delete it later.
Example commands
Run a PHP script:
/usr/local/bin/php /home/yourusername/public_html/cron.php >/dev/null 2>&1
Run a script that needs to start in its own folder (many apps, including Laravel, expect this):
cd /home/yourusername/public_html && /usr/local/bin/php artisan schedule:run >/dev/null 2>&1
Visit a web address (for software that gives you a cron URL):
curl -s "https://yourdomain.co.nz/cron.php?key=yourkey" >/dev/null 2>&1
The >/dev/null 2>&1 at the end throws away the output so you don't get an email every time the job runs. Leave it off while you're testing if you want to see the results (see "Getting emails from cron" below).
Using a specific PHP version
/usr/local/bin/php runs the account's default PHP version. If your site uses a different version in MultiPHP Manager (see Change your PHP version and settings), use that version's path instead so the script behaves the same as your site. For example, for PHP 8.3:
/opt/cpanel/ea-php83/root/usr/bin/php /home/yourusername/public_html/cron.php >/dev/null 2>&1
Change 83 to match your version, for example 82 for PHP 8.2 or 84 for PHP 8.4.
WordPress: replace WP-Cron with a real cron job
By default, WordPress only runs its scheduled tasks when someone visits your site. On a quiet site, scheduled posts and emails can run late. On a busy site, it checks on every page load, which wastes resources. A real cron job fixes both.
- In File Manager, edit
wp-config.phpand add this line above/* That's all, stop editing! */:define( 'DISABLE_WP_CRON', true ); - In Cron Jobs, add a job set to Twice Per Hour (or every 15 minutes) with this command:
cd /home/yourusername/public_html && /usr/local/bin/php wp-cron.php >/dev/null 2>&1
Getting emails from cron
At the top of the Cron Jobs page, enter an address under Cron Email and click Update Email. Any job without >/dev/null 2>&1 on the end will email you its output each time it runs. This is handy for testing, but add it back once the job is working or your inbox will fill up quickly.
How often should it run?
Only as often as your software needs. Every 15 or 30 minutes is plenty for most tasks. Jobs that run every minute count towards your account's resource limits and can slow your site. See What are resource limits?
Troubleshooting
- The job doesn't seem to run: remove
>/dev/null 2>&1, set a Cron Email, and check the email for errors. "No such file or directory" means the path is wrong. - The script works in the browser but not from cron: it probably expects to be run from its own folder. Use the
cd ... &&form shown above. - Errors about a missing function or the wrong PHP version: use the PHP path that matches your site's version, as shown above.
Need help?
If you get stuck, open a support ticket with the command you're trying to run, and we'll help.







