Cron runs tasks on a schedule: sending queued emails, generating sitemaps, running WordPress or WHMCS automation, or cleaning up temporary files. In DirectAdmin you manage your user's crontab under Cron Jobs. This guide explains the fields and the commands that work reliably.
Before you start
- Your package must allow cron jobs.
- Know the absolute path to your script. DirectAdmin sites live in
/home/USERNAME/domains/DOMAIN/public_html/.
Create a cron job
- Log in to DirectAdmin and go to Advanced Features → Cron Jobs.
- Click Create Cron Job.
- Fill in the time fields: Minute, Hour, Day of Month, Month, Day of Week. Use
*for "every". - Enter the Command.
- Click Create.
Schedule examples
| Minute | Hour | Day | Month | Weekday | Runs |
|---|---|---|---|---|---|
*/5 | * | * | * | * | Every 5 minutes |
0 | * | * | * | * | Every hour |
15 | 3 | * | * | * | Daily at 03:15 |
0 | 4 | * | * | 1 | Mondays at 04:00 |
Times are in the server's time zone. Avoid running heavy jobs every minute; every 5 or 15 minutes is enough for most applications.
Command examples
- PHP script:
/usr/local/bin/php /home/john/domains/example.com/public_html/cron.php - Specific PHP version: DirectAdmin installs versions under
/usr/local/php83/bin/php,/usr/local/php82/bin/phpand so on. Use the one your site runs. - WordPress cron: disable WP-Cron in
wp-config.phpwithdefine('DISABLE_WP_CRON', true);, then run/usr/local/bin/php /home/john/domains/example.com/public_html/wp-cron.phpevery 15 minutes. - Fetch a URL:
/usr/bin/curl -s https://example.com/cron-endpoint >/dev/null
Logging and notifications
Cron emails any output to the address in Send all cron output to E-Mail Address at the top of the Cron Jobs page. To keep a log instead, append:
>> /home/john/cron.log 2>&1To silence a job completely, append >/dev/null 2>&1. Silence only jobs you have already tested.
Prevent overlapping runs
If a job can take longer than its interval, two copies may run at the same time and fight over the same data. Wrap the command with flock so a new run is skipped while the previous one is still busy:
/usr/bin/flock -n /home/john/cron.lock /usr/local/bin/php /home/john/domains/example.com/public_html/cron.phpAlso spread heavy jobs across different minutes (for example 7 and 37 instead of 0 and 30) so they do not start at the same moment as everyone else's tasks.
Edit or delete
Click a cron job to change it, or tick it and click Delete. Add a comment-like note to the command, for example # sitemap at the end, so you remember what each job does.
Troubleshooting
- Command not found: cron has a minimal
PATH. Always use full paths tophp,curland scripts. - Script works in the browser but not in cron: relative includes fail because the working directory differs. Add
cd /home/john/domains/example.com/public_html &&before the command. - Wrong PHP version:
/usr/local/bin/phpis the default version, which may differ from your site's version. - Too many emails: remove the email address or silence output.
