Start free · Free tools · Fair usage limits
Browse Tools

Categories

Custom AI Solutions – AI2Flows
LIVE NEWS
Loading latest AI & SEO news…
Home›Tools›Crontab Builder›How to run a cron job on the last day of the month
Cron expression

How to run a cron job on the last day of the month

How to schedule a cron job on the last day of the month: why one expression isn’t enough, a copy-ready crontab workaround, and next run times.

Quick answer

Standard cron cannot run a job on the last day of the month with one plain expression. Standard cron has no “last day” value. The usual fix is one crontab line with a short shell check, shown below, which you can copy straight into crontab -e.

Last updated · Maintained by FreeAIToolz · How we test

At 23:00 (11:00 PM) on days 28 to 31 of the month

Open in the full Crontab Builder →

Copy-ready crontab to run a job on the last day of the month

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

date -d tomorrow is GNU date (Linux). On macOS/BSD use date -v+1d +\%d instead.

What does 0 23 28-31 * * mean?

At 23:00 (11:00 PM) on days 28 to 31 of the month. This is the base schedule used by the workaround above.

FieldValueAllowedMeaning
Minute00–590
Hour230–2323
Day of month28-311–3128, 29, 30, 31
Month*1–12every month
Day of week*0–6 (0 = Sunday)every day of week

Example run times

If the current time were Monday 4 January 2027, 08:58 UTC, 0 23 28-31 * * would next run at:

  1. Thu 28 Jan 2027, 23:00 UTC
  2. Fri 29 Jan 2027, 23:00 UTC
  3. Sat 30 Jan 2027, 23:00 UTC
  4. Sun 31 Jan 2027, 23:00 UTC
  5. Sun 28 Feb 2027, 23:00 UTC
  6. Sun 28 Mar 2027, 23:00 UTC

When to use a cron job on the last day of the month

Month-end closing, final invoices and end-of-month exports.

Things to watch out for

Standard cron has no “last day” value. Quartz and some schedulers support L, but crontab does not. The expression shown runs on days 28–31; add a check so it only continues when tomorrow is the 1st.

How to use this schedule in your scheduler

Schedulers below run the base expression 0 23 28-31 * *. Put the same check (shown in the crontab line) at the start of your job so it exits early on the days it should not run.

Linux crontab

Run crontab -e and add:

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

GitHub Actions

on:
  schedule:
    - cron: '0 23 28-31 * *'   # UTC

Kubernetes CronJob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: my-job
spec:
  schedule: "0 23 28-31 * *"
  timeZone: "Etc/UTC"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: job
              image: busybox
              command: ["sh", "-c", "echo run"]

AWS EventBridge Scheduler

EventBridge uses six fields (with a year) and needs ? in either day-of-month or day-of-week:

cron(0 23 28-31 * ? *)

Spring @Scheduled (seconds first)

@Scheduled(cron = "0 0 23 28-31 * *", zone = "UTC")

Node.js (node-cron)

cron.schedule('0 23 28-31 * *', () => { /* job */ }, { timezone: 'UTC' });

Vercel Cron Jobs (vercel.json)

{ "crons": [{ "path": "/api/cron", "schedule": "0 23 28-31 * *" }] }

Vercel cron jobs run in UTC, and how often they can run depends on your plan.

More cron schedules

Frequently asked questions

Is there a single cron expression for on the last day of the month?
Standard cron has no “last day” value. Quartz and some schedulers support L, but crontab does not. The expression shown runs on days 28–31; add a check so it only continues when tomorrow is the 1st. date -d tomorrow is GNU date (Linux). On macOS/BSD use date -v+1d +\%d instead.
Which time zone does this cron schedule use?
Cron runs in the time zone of the system or service that executes it. Linux servers and cloud schedulers (GitHub Actions, Vercel, AWS EventBridge by default) normally use UTC. Many crontabs accept CRON_TZ=Area/City at the top, and Kubernetes CronJobs have a timeZone field.
What happens if the server is off at the scheduled time?
Plain cron does not catch up on missed runs. If the machine was off, that run is skipped. Use anacron, or a systemd timer with Persistent=true, if missed jobs must run after boot.
How do I test this schedule before deploying?
Paste the expression into the live checker on this page to see the next 10 run times in UTC and your local time. On Linux, check the system log (grep CRON /var/log/syslog) after the first expected run.