Kitloft

All tools / Cron schedules

Cron expression for every 6 months

Runs at 00:00 on the 1st of January and the 1st of July.

Cron expression for every 6 months
0 0 1 1,7 *

Next 5 runs (your time zone: )

Field by field

FieldValueMeaning
Minute0at minute 0
Hour0at hour 00
Day of month1on the 1st
Month1,7in January and July
Day of week*any day of the week

Use it in your scheduler

crontab

Run crontab -e and add a line. Cron uses the server's time zone, which is often UTC.

crontab line
0 0 1 1,7 * /usr/local/bin/my-job.sh >> /var/log/my-job.log 2>&1

Kubernetes CronJob

Set timeZone to run the schedule in a zone other than the cluster's default.

cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: my-job
spec:
  schedule: "0 0 1 1,7 *"
  timeZone: "Etc/UTC"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: my-job
              image: busybox:1.36
              command: ["sh", "-c", "date; echo Hello from Kubernetes"]

GitHub Actions

GitHub evaluates schedules in UTC and runs them on the default branch. Runs can start a few minutes late when GitHub is busy.

.github/workflows/scheduled.yml
on:
  schedule:
    - cron: '0 0 1 1,7 *'

systemd timer

systemd timers use OnCalendar instead of cron syntax. Check the value with systemd-analyze calendar 'semiannually', or generate the full service and timer.

Timer section
[Timer]
OnCalendar=semiannually
Persistent=true

Open this schedule in the cron explainer →