directadmin

DirectAdmin Cron Jobs – Scheduling Automated Tasks

Setting up cron jobs in DirectAdmin - WordPress cron, backups, custom scripts - and understanding the schedule syntax.

5 min read

Cron is the Unix-standard scheduler that runs commands at specified times — every minute, every hour, every Monday at 3 AM, whatever you need. DirectAdmin’s cron interface lets you schedule scripts without SSH access, which covers most real-world needs: WordPress wp-cron, custom backups, periodic data fetches, cleanup tasks. This guide explains the schedule syntax, walks through common cron use cases, and shows how to set them up in DirectAdmin.

Accessing cron in DirectAdmin

  • DirectAdmin → User Level → Advanced FeaturesCron Jobs.

The Cron Jobs page shows existing scheduled tasks and a form to create new ones.

Cron syntax — the five time fields

Every cron job has five time fields plus the command:

minute  hour  day-of-month  month  day-of-week  command
   *      *        *           *         *        /path/to/command
FieldRangeExamples
Minute0-590 = top of hour, */5 = every 5 min
Hour0-230 = midnight, 14 = 2 PM
Day of month1-311 = first day, 15 = mid-month
Month1-121 = January, 12 = December
Day of week0-60 or 7 = Sunday, 1 = Monday

Asterisk (*) means “any value”. Commas list specific values (1,3,5). Slashes give step values (*/10 = every 10).

Common schedule examples

ScheduleMeaning
* * * * *Every minute
*/15 * * * *Every 15 minutes
0 * * * *Every hour on the hour
0 3 * * *Every day at 3:00 AM
30 2 * * 0Every Sunday at 2:30 AM
0 0 1 * *First day of month at midnight
0 9-17 * * 1-5Every hour 9-17 weekdays

For complex schedules, crontab.guru is invaluable — type a schedule, it tells you in plain English when it runs.

Creating a cron job in DirectAdmin

  1. Advanced Features → Cron Jobs.
  2. Fill in the time fields (Minute, Hour, etc.).
  3. Command: the actual command to run.
  4. Add.

Cron runs immediately on the next scheduled occurrence. Check by looking at the cron job list (it’ll appear there) and by examining results after the scheduled time.

Common use cases

WordPress cron (wp-cron.php)

WordPress has built-in scheduled tasks (publish scheduled posts, run plugin updates, check for new versions). By default these run on every page request — wasteful on busy sites and unreliable on quiet ones.

Better approach: disable WordPress’s built-in trigger and run wp-cron.php as a system cron job.

  1. Edit wp-config.php, add: define( 'DISABLE_WP_CRON', true );
  2. In DirectAdmin Cron Jobs, add:
  • Schedule: */15 * * * * (every 15 minutes).
  • Command: cd /home/youruser/domains/yourdomain.com/public_html && /usr/local/bin/php wp-cron.php >/dev/null 2>&1

Result: WordPress’s scheduled tasks run reliably every 15 minutes, regardless of site traffic.

Backup database to a file

0 3 * * * mysqldump -u dbuser -p'dbpassword' dbname > /home/youruser/backups/db-$(date +%Y%m%d).sql

Daily at 3 AM, dump database to dated file. Note the escaped % — cron interprets % specially, so escape it.

For more sophisticated backups, JetBackup (where available) is preferred. JetBackup guide.

Clean up old log files

0 1 * * 0 find /home/youruser/domains/yourdomain.com/public_html/logs -mtime +30 -delete

Every Sunday at 1 AM, delete log files older than 30 days.

Hit a URL periodically (webhook, ping)

*/5 * * * * curl -s https://yourdomain.com/cron-endpoint.php >/dev/null

Every 5 minutes, request a URL. Useful for webhook-driven applications, data sync endpoints, etc.

Run a custom PHP script

0 * * * * /usr/local/bin/php /home/youruser/domains/yourdomain.com/public_html/scripts/hourly-task.php

Hourly, run your script. Useful for data imports, third-party API syncs, periodic data processing.

Setting the PHP version

Default /usr/local/bin/php may point to a different PHP version than your website uses. To use a specific version, find its path. Common paths on DirectAdmin:

  • PHP 8.2: /usr/local/php82/bin/php
  • PHP 8.1: /usr/local/php81/bin/php
  • PHP 7.4: /usr/local/php74/bin/php

Specify the full path in your cron command:

0 * * * * /usr/local/php82/bin/php /home/youruser/script.php

Capturing output

By default cron emails the output of every job to the account email. For frequent jobs, this floods your inbox.

  • Discard output entirely: append >/dev/null 2>&1
  • Log output to a file: append >> /home/youruser/cron.log 2>&1
  • Email only on errors: append > /dev/null (sends stderr only — silent on success, emails on error)

2>&1 = redirect stderr (file descriptor 2) to stdout (file descriptor 1). So >file 2>&1 sends both regular output and errors to the same file.

Cron job paths — full paths matter

Cron runs commands with a minimal environment — no PATH set up like an interactive shell. Always use full paths:

  • Right: /usr/local/bin/php /home/user/script.php
  • Wrong: php script.php (fails — cron doesn’t know where php lives)

To find a binary’s full path interactively: which php, which curl, etc.

Testing cron jobs

  1. First, test the command manually (SSH session, or DA File Manager terminal where available). Run the exact command and see if it works.
  2. Once command works manually, schedule it.
  3. Set the schedule to run soon (e.g. every minute) for initial test.
  4. Wait, check output / log file.
  5. Once verified working, change schedule to the actual frequency you want.

Resist the urge to set * * * * * forever — every-minute jobs add up. Most tasks are fine hourly or daily.

Common cron issues

“Cron job doesn’t run.” Most common cause: incorrect path. The command that works in your SSH session uses different path settings than cron’s. Use full paths everywhere.

“Cron runs but does nothing visible.” Output discarded with >/dev/null. Capture to a log file to see what’s happening: >> /home/youruser/cron.log 2>&1.

“WordPress scheduled posts not publishing.” wp-cron disabled but no replacement cron job. Either re-enable WP’s built-in cron (remove DISABLE_WP_CRON) or set up the system cron job described above.

“Permission denied error in cron output.” Script lacks execute permissions, or referenced file owned by wrong user. Check file permissions; check ownership.

“PHP fatal error: cannot find file.” Working directory differs from when you run interactively. Use absolute paths in your scripts, or cd /path && php script.php in the cron command.

“Cron sends me hundreds of error emails per day.” Job is failing silently. Either fix the script, or capture errors to a log file and remove email output. Don’t just suppress — you’ll miss real problems.

DirectAdmin cron permissions

Resellers can enable/disable cron for their users. Some plans restrict cron access:

  • If “Cron Jobs” doesn’t appear under Advanced Features, your account doesn’t have cron enabled.
  • Open a ticket to request cron enablement.

What’s next

  • WordPress task scheduling: replace WP’s built-in cron with system cron (above section).
  • Database backups via cron + JetBackup combination.
  • For complex automation, consider VPS with full SSH access: Managed vs unmanaged VPS.

Cron handles the unglamorous backbone of automated site operations. Once set up, jobs run silently for years without intervention — exactly the right characteristic for the boring necessary tasks they handle. Test carefully on setup, capture logs, then forget about them.

Was this helpful?