Run Cron Every 5 Minutes
Expression: */5 * * * *
How It Works
The */5 means "every 5 minutes" - it runs at minutes 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55.
Real-World Examples
๐ Monitoring & Health Checks
*/5 * * * * /scripts/health-check.sh- Check server health every 5 minutes*/5 * * * * curl -s https://api.example.com/health- Monitor API endpoint
๐ Data Sync
*/5 * * * * /scripts/sync-database.sh- Sync database every 5 minutes*/5 * * * * rsync -av /source/ /destination/- Backup files periodically
๐ง Email & Notifications
*/5 * * * * /scripts/check-alerts.sh- Check and send alerts*/5 * * * * /scripts/process-queue.sh- Process email queue
๐งน Cleanup Tasks
*/5 * * * * find /tmp -type f -mmin +10 -delete- Clean temp files older than 10 minutes*/5 * * * * /scripts/clear-cache.sh- Clear application cache
Variations
*/5 * * * *- Every 5 minutes*/10 * * * *- Every 10 minutes*/15 * * * *- Every 15 minutes*/30 * * * *- Every 30 minutes
Best Practices
- Don't run too frequently - every 5 minutes is usually the minimum needed
- Consider system load when scheduling frequent jobs
- Use logging to track job execution and diagnose issues
- Set up alerts for job failures