DevToolPal
EN

Cron expression

Last day of every month

Standard cron has no "last day" symbol, so the job runs on days 28–31 and a shell test lets it continue only when tomorrow is the 1st.

0 0 28-31 * * Open in Cron Expression Parser

The crontab line uses GNU date (date -d tomorrow); on macOS use date -v+1d. Quartz and Spring support L directly. In Kubernetes and GitHub Actions, add the same date check at the start of the job.

Field by field

Field Value Matches
Minute 0 0
Hour 0 0
Day of month 28-31 28, 29, 30, 31
Month * Every value
Day of week * Every value

Next run times

Example: the first 6 runs after January 1, 2026 (UTC).

  1. Sat, Jan 31, 2026, 00:00
  2. Sat, Feb 28, 2026, 00:00
  3. Tue, Mar 31, 2026, 00:00
  4. Thu, Apr 30, 2026, 00:00
  5. Sun, May 31, 2026, 00:00
  6. Tue, Jun 30, 2026, 00:00

Ready-to-use versions

crontab
0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = 01 ] && /path/to/command

Add the line with crontab -e. It runs in the server's time zone unless CRON_TZ or TZ is set.

Kubernetes CronJob
apiVersion: batch/v1
kind: CronJob
metadata:
  name: last-day-of-month
spec:
  schedule: "0 0 28-31 * *"
  timeZone: "Etc/UTC"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: job
              image: busybox:1.36
              command: ["/bin/sh", "-c", "date; echo run"]

Set spec.timeZone (Kubernetes 1.27+); without it the schedule follows the controller manager's time zone, usually UTC.

GitHub Actions
on:
  schedule:
    - cron: '0 0 28-31 * *'
  workflow_dispatch:

GitHub Actions always uses UTC, accepts intervals of 5 minutes or more, and may start scheduled runs late under load.

Quartz
0 0 0 L * ?

Quartz puts seconds first and needs ? in either day-of-month or day-of-week. Days are 1–7 from Sunday, so names are safer.

Spring
@Scheduled(cron = "0 0 0 L * *")

Spring @Scheduled(cron = …) takes six fields: seconds, then the usual five.

FAQ

› Why is % escaped as \% in crontab?

In a crontab line, % means newline (input for the command). Write \% so the date format reaches the shell intact.

› Which time zone does 0 0 28-31 * * run in?

Cron uses the time zone of the machine or service that runs it. On Linux that is the system time zone unless CRON_TZ or TZ is set; Kubernetes CronJobs accept spec.timeZone; GitHub Actions always uses UTC.

› How can I check this schedule before deploying it?

Open 0 0 28-31 * * in the Cron Expression Parser on this site. It explains each field and lists the upcoming runs in your local time or UTC, right in your browser.