How to set up a cron job Print

  • 0

A cron job runs a command or script on a schedule, for example every 15 minutes or once a day. You might need one if a plugin, booking system or shop asks you to "set up a cron".

  1. Log in to cPanel (see How to log in to cPanel).
  2. In the Advanced section, click Cron Jobs.
  3. Scroll to Add New Cron Job.
  4. Pick how often it should run from Common Settings, for example Once Per Hour. The Minute, Hour, Day, Month and Weekday boxes fill in for you.
  5. In Command, enter the command your software gave you (see the examples below).
  6. Click Add New Cron Job.

Add New Cron Job form in cPanel

Example commands

Replace username with your cPanel username and the path with your own.

Run a PHP script/usr/local/bin/php /home/username/public_html/script.php
Visit a web address/usr/bin/curl -s https://yourdomain.com/cron.php
Run without sending an emailadd >/dev/null 2>&1 to the end of the command

Emails from cron

By default, cron emails you the output every time a job runs. Set the address under Cron Email at the top of the page, or add >/dev/null 2>&1 to the end of a command to stop its emails.

Tip: Please don't run jobs more often than every 5 minutes unless your software needs it. Very frequent jobs use up your account's resources and can slow your site down.

WordPress and cron

WordPress runs its own scheduled tasks when people visit your site. On busy or very quiet sites you can switch this to a real cron job: add define('DISABLE_WP_CRON', true); to wp-config.php, then add a cron job that runs every 15 minutes with this command:

/usr/bin/curl -s https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

Still stuck? Open a support ticket and we'll help.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution