What is a Cron Job?

A cron job is a scheduled task that runs automatically at specified intervals. Common uses:

  • Running a backup script
  • Clearing a cache
  • Sending automated emails
  • Running a PHP maintenance script

Setting Up in DirectAdmin

  1. Log in to DirectAdmin
  2. Go to Advanced FeaturesCron Jobs
  3. Click Create a Cron Job
  4. Set the schedule:
- Minute (0–59) - Hour (0–23) - Day of Month (1–31) - Month (1–12) - Day of Week (0–7, where 0 and 7 = Sunday)
  1. Enter the command to run
  2. Click Create

Common Examples

Run a PHP script every hour:

0     /usr/local/bin/php /home/username/domains/example.com/public_html/cron.php

Run a script every day at midnight:

0 0   * /usr/local/bin/php /home/username/domains/example.com/public_html/daily.php

Run a script every 5 minutes:

/5    * /usr/local/bin/php /home/username/domains/example.com/public_html/check.php

Tips

  • Use full paths for both the PHP binary and your script
  • Use >/dev/null 2>&1 at the end to suppress email output
  • Test your script manually via SSH first before scheduling it