How to Schedule Cron Jobs

Updated 25 February 2026 11 views Hosting & Servers

Automating Tasks with Cron Jobs

Cron jobs allow you to schedule commands or scripts to run automatically at specified intervals. They are essential for tasks like sending scheduled emails, running database maintenance, generating reports, or triggering WordPress scheduled tasks.

Setting Up a Cron Job in DirectAdmin

  1. Log in to your DirectAdmin control panel.
  2. Navigate to Advanced Features > Cron Jobs.
  3. Click Create Cron Job.
  4. Set the schedule using the five time fields:
    • Minute (0–59)
    • Hour (0–23)
    • Day of Month (1–31)
    • Month (1–12)
    • Day of Week (0–6, where 0 is Sunday)
  5. Enter the command to execute.
  6. Click Save.

Common Cron Job Examples

  • WordPress cron (every 15 minutes):
    */15 * * * * /usr/local/bin/php /home/username/domains/yourdomain.com/public_html/wp-cron.php
  • Database backup (daily at 2:00 AM):
    0 2 * * * /usr/local/bin/mysqldump -u dbuser -pPassword dbname > /home/username/backups/db_backup.sql
  • Clear temp files (weekly on Sunday):
    0 3 * * 0 rm -rf /home/username/tmp/*

Cron Schedule Shortcuts

  • * * * * * – Every minute
  • 0 * * * * – Every hour
  • 0 0 * * * – Every day at midnight
  • 0 0 * * 0 – Every Sunday at midnight
  • 0 0 1 * * – First day of every month

Best Practices

  • Always use full paths for both the interpreter and the script.
  • Redirect output to a log file or to /dev/null to avoid receiving cron emails: command > /dev/null 2>&1
  • Test your command manually via SSH before adding it as a cron job.
  • Avoid running cron jobs too frequently on shared hosting as this can impact server resources.

Was this article helpful?

Let us know so we can improve our docs.