Creating a Cron Job Print

  • 0

A cron job runs a command or script automatically on a schedule. For example, you could send a daily report, clear a cache every hour or run WordPress scheduled tasks reliably.

Add a cron job

  1. In cPanel, go to Advanced › Cron Jobs.
  2. (Optional) Under Cron Email, enter an address to receive any output from your jobs.
  3. Under Add New Cron Job, pick a schedule from Common Settings, or fill in the Minute, Hour, Day, Month and Weekday boxes yourself.
  4. Enter the Command (see the examples below) and click Add New Cron Job.

Schedule examples

Minute Hour Day Month Weekday Runs
*/15 * * * * Every 15 minutes
0 * * * * Every hour, on the hour
30 2 * * * Every day at 02:30
0 9 * * 1 Every Monday at 09:00
0 0 1 * * Midnight on the 1st of each month
Note: Cron times use the server's time zone, which may differ from yours.

Command examples

Replace username with your cPanel username.

Run a PHP script

/usr/local/bin/php /home/username/public_html/scripts/report.php >/dev/null 2>&1

Run WordPress scheduled tasks

/usr/local/bin/php /home/username/public_html/wp-cron.php >/dev/null 2>&1

Then add define('DISABLE_WP_CRON', true); to wp-config.php so WordPress doesn't also run them on every page visit. Every 5–15 minutes is usually enough.

Laravel scheduler (every minute)

cd /home/username/myapp && /usr/local/bin/php artisan schedule:run >/dev/null 2>&1

Use a specific PHP version

/opt/cpanel/ea-php83/root/usr/bin/php /home/username/public_html/script.php
Tip: Adding >/dev/null 2>&1 to the end of a command stops it from emailing you every time it runs. Remove it while you're testing so you can see any errors.
Important: Please don't schedule heavy jobs more often than they need to run. Very frequent cron jobs can slow your website down and may breach our fair-use policy.

Still stuck? Contact Raleway support and our team will be happy to help.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution