How do I use Cron Jobs in DirectAdmin?
21 viewsHow do I use Cron Jobs in DirectAdmin?
Overview
Cron Jobs allow you to schedule automatic tasks on your server, such as running scripts, sending emails, or performing maintenance tasks at set intervals. This is useful for backups, updates, and automation.
Step-by-Step Guide
1. Log in to your control panel
- Access your hosting control panel
- Sign in with your account credentials
2. Open Cron Jobs section
- Navigate to Advanced Features
- Click Cron Jobs
3. Choose a schedule
Select how often the task should run:
- Every minute
- Hourly
- Daily
- Weekly
- Monthly
- Custom timing (advanced users)
You can also manually set timing using:
- Minute
- Hour
- Day of month
- Month
- Day of week
4. Enter the command
In the command field, enter the script or command you want to run.
Examples:
-
Run a PHP script:
/usr/local/bin/php /home/username/public_html/script.php -
Run a WordPress cron manually:
wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
5. Create the cron job
- Click Create
- The task will now run automatically based on your schedule
Important Notes
- Incorrect cron commands can cause errors or resource issues
- Always test scripts manually before scheduling them
- Avoid running tasks too frequently unless necessary
- Some hosting plans may limit cron job frequency
Common Issues & Fixes
Cron job not running
- Check command path is correct
- Ensure script has proper permissions
- Verify scheduling timing is set correctly
Command works manually but not in cron
- Use full file paths instead of relative paths
- Ensure environment variables are properly set
- Redirect output to avoid hidden errors
Too many emails from cron
-
Add this to suppress output:
>/dev/null 2>&1
Need Help?
If your cron job is not executing correctly or you’re unsure how to structure a command, support can help review your setup and ensure it runs as expected.