⏰ Cron Jobs Configuration
Creating Cron Jobs
- Navigate to Sites → Cron Jobs
- Click "Add new Cron Job"
- Configure cron settings:
- Parent website: Select website
- Minutes: 0-59 or * for every minute
- Hours: 0-23 or * for every hour
- Days: 1-31 or * for every day
- Months: 1-12 or * for every month
- Weekdays: 0-7 (0 and 7 = Sunday) or *
- Command: Full command to execute
- Active: Yes
- Save cron job
Cron Schedule Format
* * * * * command
│ │ │ │ │
│ │ │ │ └─── Day of week (0-7, 0/7=Sunday)
│ │ │ └───── Month (1-12)
│ │ └─────── Day of month (1-31)
│ └───────── Hour (0-23)
└─────────── Minute (0-59)
Common Cron Schedule Examples
Schedule | Description | Cron Format |
---|---|---|
Every minute | Runs every minute | * * * * * |
Every hour | At minute 0 of every hour | 0 * * * * |
Daily at midnight | At 00:00 every day | 0 0 * * * |
Daily at 2:30 AM | At 02:30 every day | 30 2 * * * |
Weekly on Sunday | Sunday at midnight | 0 0 * * 0 |
Monthly | 1st day at midnight | 0 0 1 * * |
Every 5 minutes | At minutes 0,5,10,15... | */5 * * * * |
Business hours | Mon-Fri, 9AM-5PM | 0 9-17 * * 1-5 |
Cron Command Examples
PHP Scripts
# Run PHP script
/usr/bin/php /var/www/clients/client1/web1/web/cron.php
# With specific PHP version
/usr/bin/php7.4 /var/www/clients/client1/web1/web/script.php
# WordPress cron
/usr/bin/php /var/www/clients/client1/web1/web/wp-cron.php
Shell Scripts
# Run bash script
/bin/bash /var/www/clients/client1/web1/private/backup.sh
# Make script executable first
chmod +x /var/www/clients/client1/web1/private/script.sh
URL Fetch (wget/curl)
# Fetch URL with wget
/usr/bin/wget -q -O /dev/null https://yourdomain.com/cron.php
# Using curl
/usr/bin/curl -s https://yourdomain.com/cron.php > /dev/null
Cron Job Output and Logging
Redirect Output
# Discard output
command > /dev/null 2>&1
# Log to file
command >> /var/log/mycron.log 2>&1
# Log errors only
command > /dev/null 2>> /var/log/cron-errors.log
# Log everything with timestamp
echo "$(date): Starting cron" >> /var/log/cron.log
command >> /var/log/cron.log 2>&1
Email Notifications
Cron sends output to email by default. To control this:
# Disable email
MAILTO=""
# Send to specific email
MAILTO="admin@yourdomain.com"
# At beginning of crontab or in ISPConfig command field
MAILTO="admin@yourdomain.com"
0 0 * * * /path/to/script.sh
Common Cron Job Tasks
- Database backup: Daily MySQL dumps
- Log rotation: Archive old logs
- Cache clearing: Remove temporary files
- Data synchronization: Sync with external services
- Report generation: Create daily/weekly reports
- WordPress maintenance: wp-cron.php execution
- Email queue processing: Send queued emails
- Sitemap generation: Update XML sitemaps
Troubleshooting Cron Jobs
- Not running: Check if cron job is active
- Permission denied: Verify file permissions and ownership
- Command not found: Use full paths to commands
- Wrong user: Cron runs as web user, not root
- No output: Check log redirection
- Time zone issues: Server time zone affects schedule
Testing Cron Commands
- Test command manually first:
su - web1 -s /bin/bash /usr/bin/php /var/www/clients/client1/web1/web/test.php
- Check cron logs:
grep CRON /var/log/syslog tail -f /var/log/cron.log
- List user's cron jobs:
crontab -u web1 -l
Tip: Always use absolute paths in cron commands and test commands manually before scheduling them.