UnderHost
Knowledgebase Docs

How to set up cron jobs in CloudPanel

Schedule automated tasks per site using CloudPanel's built-in cron job manager. Includes examples for WordPress wp-cron, PHP scripts, and database maintenance.

On this page

CloudPanel includes a per-site cron job manager. Cron jobs created here run as the site's system user, so they have access to that site's files and the correct PHP environment without needing root.

Create a cron job

  1. Log in to CloudPanel and go to Sites → your site
  2. Click the Cron Jobs tab
  3. Click Add Cron Job
  4. Set the schedule using the minute/hour/day/month/weekday fields, or enter a cron expression
  5. Enter the command to run
  6. Click Add

The cron job runs as the site's system user. Use the full path to PHP and your script file. The PHP binary path on CloudPanel is typically:

/usr/bin/php8.1

Or for the system default PHP:

/usr/bin/php

Cron schedule syntax

Five fields: minute hour day month weekday

ScheduleExpression
Every 5 minutes*/5 * * * *
Every hour0 * * * *
Every day at midnight0 0 * * *
Every day at 3am0 3 * * *
Every Sunday at 1am0 1 * * 0

Common examples

WordPress dedicated cron (every 5 minutes):

/usr/bin/php /home/SYSTEM_USER/htdocs/yourdomain.com/wp-cron.php > /dev/null 2>&1

After adding this, disable WordPress's built-in wp-cron by adding to wp-config.php:

define('DISABLE_WP_CRON', true);

Daily database backup at 3am:

mysqldump -u DB_USER -pDB_PASS DB_NAME | gzip > /home/SYSTEM_USER/backups/db-$(date +\%Y\%m\%d).sql.gz

Clear a cache directory hourly:

find /home/SYSTEM_USER/htdocs/yourdomain.com/cache/ -name "*.php" -mtime +1 -delete

Cron not running

  • Wrong PHP version path: Use which php8.1 or which php over SSH to find the correct binary path for your installed PHP version
  • Wrong file path: Cron requires the full absolute path. The site's document root is /home/SYSTEM_USER/htdocs/yourdomain.com/-replace with your actual system user and domain
  • Script errors: Remove > /dev/null 2>&1 temporarily so output is emailed to the system user. Check the error to diagnose
  • Output email not received: The cron system sends output to the system user's local mailbox. Check /var/mail/SYSTEM_USER via SSH if you are not receiving emails
  • Percent signs in commands: In crontab, % is a special character. Escape it as \% in date format strings

Related: How to create a website in CloudPanel | Backups in CloudPanel-files and databases | How to connect to your VPS via SSH | CloudPanel troubleshooting-common issues and fixes

Was this article helpful?

Need CloudPanel on a server?

Use CloudPanel on an UnderHost VPS or dedicated server for fast PHP app and WordPress hosting without a heavy panel stack.

Related articles

Back to CloudPanel