DirectAdmin

Create cron jobs in DirectAdmin

Schedule commands and PHP scripts with DirectAdmin Cron Jobs, write correct cron times, choose the right PHP binary, log output and stop unwanted emails.

IntermediateDirectAdmin2 min read

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

  1. Log in to DirectAdmin and go to Advanced Features → Cron Jobs.
  2. Click Create Cron Job.
  3. Fill in the time fields: Minute, Hour, Day of Month, Month, Day of Week. Use * for "every".
  4. Enter the Command.
  5. Click Create.

Schedule examples

MinuteHourDayMonthWeekdayRuns
*/5****Every 5 minutes
0****Every hour
153***Daily at 03:15
04**1Mondays 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/php and so on. Use the one your site runs.
  • WordPress cron: disable WP-Cron in wp-config.php with define('DISABLE_WP_CRON', true);, then run /usr/local/bin/php /home/john/domains/example.com/public_html/wp-cron.php every 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>&1

To 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.php

Also 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 to php, curl and 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/php is the default version, which may differ from your site's version.
  • Too many emails: remove the email address or silence output.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.