A cron job automatically runs a command or script at a set time – for example every 15 minutes or every night. It is used, for example, so that WordPress scheduled tasks run on time even if the website has few visitors.

Log in to cPanel – see the article “1.2. Logging in to cPanel”.

1Add a job

In the “Advanced” section of cPanel, open “Cron Jobs”. Under “Add New Cron Job”, choose the frequency in “Common Settings” or fill in “Minute”, “Hour”, “Day”, “Month”, “Weekday” (every 15 minutes: choose “Once Per Fifteen Minutes” in the “Minute” field and leave * in the other fields). Enter the command in the “Command” field and click “Add New Cron Job”.

The page also shows a PHP command example with the correct path for your account.

Add a job

Example: WordPress cron

1) In the wp-config.php file, before the line "That's all, stop editing!", add:

define( 'DISABLE_WP_CRON', true );

2) Create a cron job every 15 minutes with this command (replace /home2/lietotajs with the path to your home folder and public_html with the folder where WordPress is installed; the correct path is also shown in the example on the Cron Jobs page):

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

Recommendations

  • Do not run jobs more often than needed – “Once Per Minute” can create unnecessary load and reach the resource limits (see the article “Website is slow or shows error 508 – hosting resource limits”).
  • Add >/dev/null 2>&1 at the end, otherwise cPanel will send an email to the address in “Cron Email” after every run.
  • Existing jobs are shown under “Current Cron Jobs” – you can edit (“Edit”) or delete (“Delete”) them there.

If you run into any difficulties, just write to us and we will help. support@area.lv

Was this answer helpful? 0 Users Found This Useful (0 Votes)