How to use the Cron Job Every 30 Minutes
- Copy
*/30 * * * *and put your command after it in your crontab (open it withcrontab -e). - Check the next run times below, in UTC or your server's time zone.
- Need something slightly different? Edit any field and the description updates as you type.
The crontab line
*/30 * * * * /path/to/your-script.sh >> /var/log/your-script.log 2>&1
The five fields are minute, hour, day of month, month and day of week. Redirecting output to a log file (>> … 2>&1) keeps errors you'd otherwise never see.
Good for
- Backing up a database that changes often
- Pulling exchange rates or prices
- Cleaning up temporary files
Variations
0,30 * * * * | The same schedule, written as a list |
15,45 * * * * | At quarter past and quarter to |
*/30 8-20 * * * | Every 30 minutes from 8:00 AM to 8:30 PM |
Same schedule elsewhere
| GitHub Actions | on: schedule: - cron: '*/30 * * * *' (always UTC) |
|---|---|
| Kubernetes | spec.schedule: "*/30 * * * *" in a CronJob |
| Vercel | "crons": [{"path": "/api/job", "schedule": "*/30 * * * *"}] in vercel.json |
Frequently asked questions
Why not use */45 for every 45 minutes?
Steps restart every hour, so */45 runs at :00 and :45, then :00 again 15 minutes later. Cron can't do “every 45 minutes” evenly. Run every 15 minutes and skip runs in your script instead.
What time zone does it use?
The time zone of the machine or service running cron, which is usually UTC on servers and cloud schedulers. GitHub Actions always uses UTC.