UnderHost
Knowledgebase Docs

How to set up cron jobs in DirectAdmin

Schedule automated tasks in DirectAdmin using the built-in cron job manager. Run PHP scripts, WordPress wp-cron, and shell commands on a recurring schedule.

On this page

A cron job is an automated task that runs on your server at a set schedule-every hour, every day, or at a specific time. Common uses include running WordPress scheduled tasks, sending automated reports, and clearing temporary files.

What is a cron job?

Cron jobs run independently of website visitors. They execute server-side commands or PHP scripts at the interval you define. They are useful for:

  • Running WordPress scheduled tasks (instead of relying on visitor-triggered wp-cron)
  • Sending scheduled email reports from a PHP script
  • Database cleanup tasks
  • Pulling data from an external API on a schedule
  • Automated backup scripts

Create a cron job

  1. Log in to DirectAdmin
  2. Go to Advanced Features → Cron Jobs (or Extra Features → Cron Manager)
  3. Enter the schedule (minute, hour, day, month, day of week)
  4. Enter the command to run
  5. Click Add

For most tasks, send output to null to avoid receiving cron output emails on every run:

/usr/local/bin/php /home/username/domains/yourdomain.com/public_html/cron.php > /dev/null 2>&1

Replace username with your account username and adjust the path to your script.

Cron schedule syntax

The schedule fields in order: minute hour day month weekday

ScheduleCron expression
Every minute* * * * *
Every 5 minutes*/5 * * * *
Every hour (at :00)0 * * * *
Every day at midnight0 0 * * *
Every day at 6am0 6 * * *
Every Monday at 9am0 9 * * 1
1st of every month0 0 1 * *

Common examples

WordPress-dedicated cron (every 5 minutes):

*/5 * * * * /usr/local/bin/php /home/username/domains/yourdomain.com/public_html/wp-cron.php > /dev/null 2>&1

When using a dedicated cron for WordPress, disable the built-in wp-cron by adding this to wp-config.php:

define('DISABLE_WP_CRON', true);

Fetch a PHP script via URL (every hour):

0 * * * * /usr/bin/wget -q -O /dev/null https://yourdomain.com/cron.php

Cron not running

  • Wrong PHP path: The path to PHP varies by server. Try /usr/local/bin/php or /usr/bin/php. Run a test cron that outputs the PHP version to a log file to confirm
  • Wrong file path: Use the full absolute path to the script. Relative paths do not work in cron jobs
  • Script errors: Enable output temporarily (remove > /dev/null 2>&1) and check your email for error messages
  • Permissions: The script file must be readable and executable by the server user
  • Resource limits: On shared hosting, cron jobs are subject to the same CloudLinux resource limits as web requests

Related: DirectAdmin overview | PHP versions | Cron jobs in cPanel

Was this article helpful?

Need DirectAdmin hosting?

DirectAdmin is available for customers who want a lightweight hosting control panel on compatible UnderHost services.

Related articles

Back to DirectAdmin