Cron expression for every year on january 1st
At 00:00 on day 1 in January
| Syntax | Expression |
|---|---|
| Unix crontab | 0 0 1 1 * |
| Spring @Scheduled | 0 0 0 1 1 * |
| Quartz | 0 0 0 1 1 ? |
Open and edit in the explainer →
Next run times (UTC)
- Calculating…
Configuration examples
crontab
# crontab -e
0 0 1 1 * /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 0 0 1 1 *", 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 0 0 1 1 ?")
.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: "0 0 1 1 *"
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: '0 0 1 1 *' # UTC GitHub Actions always runs in UTC. Convert from UTC before using this.
More cron examples
Every minuteEvery 5 minutesEvery 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 10 secondsEvery 30 seconds