Cron explainer › Examples

Cron expression for every 10 minutes during business hours

Every 10 minutes, between 09:00 and 18:59 on weekdays (Mon–Fri)

SyntaxExpression
Unix crontab */10 9-18 * * 1-5
Spring @Scheduled 0 */10 9-18 * * MON-FRI
Quartz 0 */10 9-18 ? * MON-FRI

Open and edit in the explainer →

Tip 9-18 includes runs up to 18:50. Add a second expression if you need to stop at exactly 18:00.

Next run times (UTC)

  1. Calculating…

Configuration examples

crontab

# crontab -e
*/10 9-18 * * 1-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 */10 9-18 * * MON-FRI", 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 */10 9-18 ? * MON-FRI")
        .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: "*/10 9-18 * * 1-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: '*/10 9-18 * * 1-5'  # 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 AMWeekends 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