StarDomain

Setting Up Cron Jobs

Setting Up Cron Jobs

Cron jobs let you run scripts or commands automatically on a schedule.

In cPanel

  1. Go to Cron Jobs in cPanel
  2. Set the schedule (minute, hour, day, month, weekday)
  3. Enter the command to run
  4. Click Add New Cron Job

Common Schedules

ScheduleMeaning
Every 5 min*/5 * * * *
Once daily0 0 * * *
Once weekly0 0 * * 0
Every hour0 * * * *

Common Commands

  • Run a PHP script: /usr/local/bin/php /home/username/public_html/cron.php
  • Fetch a URL: /usr/bin/wget -q -O /dev/null https://yourdomain.com/cron.php
  • Clear temp files: find /home/username/tmp -type f -mtime +7 -delete

In DirectAdmin

  1. Go to Cron Jobs in your control panel
  2. Click Create Cron Job
  3. Set the schedule and command
  4. Save

Tips

  • Always use full paths for binaries and scripts
  • Redirect output to a log: command >> /home/username/cron.log 2>&1
  • Set email notifications for failures
  • Test commands manually via SSH before adding as cron