Cron expression for every 5 minutes
Every 5 minutes
| Syntax | Expression |
|---|---|
| Unix crontab | */5 * * * * |
| Spring @Scheduled | 0 */5 * * * * |
| Quartz | 0 */5 * * * ? |
Open and edit in the explainer →
Tip */5 runs at minute 0, 5, 10 … 55 of every hour — not every 5 minutes from when the server started.
Next run times (UTC)
- Calculating…
Configuration examples
crontab
# crontab -e
*/5 * * * * /path/to/script.sh >> /var/log/job.log 2>&1 Runs in the server's system time zone. Check it with timedatectl.
Spring
@Scheduled(cron = "0 */5 * * * *", zone = "UTC")
public void runJob() {
// ...
} Requires @EnableScheduling. Without zone, the server time zone is used.
Quartz
Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity("myTrigger")
.withSchedule(CronScheduleBuilder.cronSchedule("0 */5 * * * ?")
.inTimeZone(TimeZone.getTimeZone("UTC")))
.build(); Quartz always needs "?" in either day-of-month or day-of-week.
Kubernetes
apiVersion: batch/v1
kind: CronJob
metadata:
name: my-job
spec:
schedule: "*/5 * * * *"
timeZone: "UTC"
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
command: ["sh", "-c", "echo hello"] The timeZone field is GA since Kubernetes 1.27. Without it, the kube-controller-manager time zone (usually UTC) is used.
GitHub Actions
on:
schedule:
- cron: '*/5 * * * *' # UTC GitHub Actions always runs in UTC. Convert from UTC before using this.
More cron examples
Every minuteEvery 10 minutesEvery 15 minutesEvery 30 minutesEvery hour (on the hour)Every 2 hoursEvery 6 hoursEvery day at midnightEvery day at 9 AMEvery day at 6 PMTwice a day (9:00 and 18:00)Weekdays at 9 AMEvery 10 minutes during business hoursWeekends at 10 AMEvery Monday at 9 AMEvery Sunday at midnightFirst day of every month15th of every monthLast day of every monthLast weekday of every monthSecond Monday of every monthLast Friday of every monthEvery quarter (Jan, Apr, Jul, Oct 1st)Every year on January 1stEvery 10 secondsEvery 30 seconds