Setting Up and Managing Cron Jobs

Setting Up and Managing Cron Jobs

Cron jobs let you run commands on a schedule, automatically and in the background. Common uses include triggering WordPress maintenance tasks, sending queued emails, generating reports, and keeping WooCommerce order statuses in sync.

What is a cron job?

A cron job is a scheduled command. You define two things: a schedule (when to run) and a command (what to run). KPanel's cron runner executes the command on your server at the times you specify.

  1. Log in to kpanel.kapsulecloud.com and open Websites.
  2. Click the domain you want to manage.
  3. In the site navigation bar, click Advanced, then Cron.

You will see a table listing any existing cron jobs, or an empty state if none have been created yet.

Adding a cron job

Click Add Cron Job in the top right corner. A form appears with three fields:

Schedule presets -- Quick buttons for common intervals:

ButtonCron expression
Every minute* * * * *
Every 5 min*/5 * * * *
Every hour0 * * * *
Daily 2AM0 2 * * *
Weekly Sunday0 2 * * 0
Monthly 1st0 2 1 * *

Click a preset to fill the Cron expression field automatically, or type your own expression directly into that field.

Label -- A human-readable name for this job (e.g. "WordPress tasks"). This appears in the jobs table so you can identify it at a glance.

Command -- The shell command to execute. Use full paths to avoid environment issues (see examples below).

Click Save to create the job.

Cron expression format

A cron expression has five fields separated by spaces:

minute  hour  day-of-month  month  day-of-week

Examples:

  • 0 3 * * * -- run at 3:00 AM every day
  • */15 * * * * -- run every 15 minutes
  • 0 9 * * 1 -- run at 9:00 AM every Monday
  • 0 0 1 * * -- run at midnight on the 1st of every month

Managing existing jobs

The jobs table shows each job's Label, Schedule, Command, Last run date, and Status (Active or Disabled).

For each job you can:

  • Click Disable / Enable to pause or resume it without deleting it.
  • Click Delete to permanently remove the job. You will be asked to confirm.

WordPress: replace the built-in pseudo-cron

WordPress has a built-in system called wp-cron that fires whenever someone visits your site. On low-traffic sites this is unreliable, and on high-traffic sites it creates unnecessary load. Replace it with a real server-side cron job:

Step 1 -- Disable wp-cron in wp-config.php

Connect via SFTP or the File Manager and add this line to wp-config.php, above the /* That's all, stop editing! */ line:

define('DISABLE_WP_CRON', true);

Step 2 -- Add a cron job in KPanel

  • Schedule: */5 * * * * (every 5 minutes is standard)
  • Label: WordPress cron
  • Command:
cd /var/www/[yourdomain]/htdocs && php -q wp-cron.php

Replace [yourdomain] with your actual domain folder name. You can find the correct path in Files > File Manager.

Alternatively, if WP-CLI is available on your plan:

cd /var/www/[yourdomain]/htdocs && wp cron event run --due-now

WooCommerce: scheduled actions

WooCommerce uses Action Scheduler for background tasks such as order status updates, subscription renewals, and email queue processing. These work best with a real cron job rather than wp-cron.

Once you have disabled wp-cron and set up the real cron job above, WooCommerce's Action Scheduler queue will process on every 5-minute cycle. You can monitor the queue in WooCommerce > Status > Scheduled Actions in wp-admin.

If you run a high-volume store, consider tightening the cron interval to */2 * * * * (every 2 minutes).

Checking whether a job is running

After saving a cron job, the Last run column in the table will update to show the most recent execution date once the first run has completed. If the date remains "Never" after the expected interval has passed, check:

  • The Command field for typos or incorrect file paths.
  • That the job status is Active and not Disabled.
  • The command itself by connecting via SSH and running it manually.

Troubleshooting

The command never runs Verify the file path is correct. The example cd /var/www/[yourdomain]/htdocs must match the actual folder on disk. Use File Manager to confirm.

Output is not being logged By default, cron output is discarded. To capture errors, redirect output in your command:

cd /var/www/example.com/htdocs && php wp-cron.php >> /tmp/wp-cron.log 2>&1

Permission errors The cron command runs as your site's system user. Make sure the files and directories referenced in the command are owned by or readable by that user.

Was this article helpful?

Still need help?

Our support team is here on business days, NZT.

Back to Help Centre