Cron last day of the month
The cron expression 0 23 28-31 * * runs a job at 23:00, on days 28 through 31 of the month; a date guard in the command limits it to the last day of the month. The guard exits early on the other dates, so give the job's heartbeat monitor a period that matches the real schedule, not the cron expression.
| minute | hour | day of month | month | day of week |
|---|---|---|---|---|
| 0 | 23 | 28-31 | * | * |
Next runs (UTC)
- Sat 2026-11-28 23:00 UTC (+00:00) · in 1d 19h
- Sun 2026-11-29 23:00 UTC (+00:00) · in 2d 19h
- Mon 2026-11-30 23:00 UTC (+00:00) · in 3d 19h
- Mon 2026-12-28 23:00 UTC (+00:00) · in 31d 19h
- Tue 2026-12-29 23:00 UTC (+00:00) · in 32d 19h
- Wed 2026-12-30 23:00 UTC (+00:00) · in 33d 19h
- Thu 2026-12-31 23:00 UTC (+00:00) · in 34d 19h
- Thu 2027-01-28 23:00 UTC (+00:00) · in 62d 19h
- Fri 2027-01-29 23:00 UTC (+00:00) · in 63d 19h
- Sat 2027-01-30 23:00 UTC (+00:00) · in 64d 19h
These are the times cron wakes up; the guard in the command then decides whether the job actually runs.
Notes for this schedule
L is Quartz-only). Schedule on days 28-31 and let the command check that tomorrow is the 1st.date -d tomorrow is GNU date (Linux). On macOS/BSD use date -v+1d +\%d.*-*~01 means the last day of every month.This schedule in numbers
- Cron wakes up 41 times in 2026; the guard in the command lets the job itself run on 12 of those days.
- A literal conversion of
0 23 28-31 * *would beOnCalendar=*-*-28..31 23:00:00; the timer below uses*-*~01 23:00:00instead, which expresses the intended schedule directly. - India has no daylight saving time, so this schedule keeps the same Indian time all year: 23:00 UTC is 04:30 IST the next day. To run at 23:00 India time on a UTC server, the expression is
30 17 28-31 * *. - None of this schedule's times (23:00) fall inside the next DST changes in New York or London, so in those zones it keeps its local time; the UTC time it runs at moves by an hour twice a year instead.
- GitHub Actions reads
cron:in UTC (23:00 UTC here) unless the schedule entry addstimezone: "Asia/Kolkata"; Kubernetes 1.27+ does the same withspec.timeZone, and either way it runs at 23:00 IST.CRON_TZ=inside a Kubernetes schedule string is rejected.
Next 5 runs on a UTC server, with India time
| UTC | IST (UTC+05:30) |
|---|---|
| Sun 29 Nov 2026, 04:30 (next day) | |
| Mon 30 Nov 2026, 04:30 (next day) | |
| Tue 01 Dec 2026, 04:30 (next day) | |
| Tue 29 Dec 2026, 04:30 (next day) | |
| Wed 30 Dec 2026, 04:30 (next day) |
Examples
0 23 28-31 * * if [ "$(date -d tomorrow +\%d)" = 01 ]; then /usr/local/bin/my-job.sh; fi && curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/<your-token>
# /etc/systemd/system/my-job.timer [Unit] Description=Run my-job (last day of the month) [Timer] OnCalendar=*-*~01 23:00:00 Persistent=true [Install] WantedBy=timers.target
# /etc/systemd/system/my-job.service [Unit] Description=my-job [Service] Type=oneshot ExecStart=/usr/local/bin/my-job.sh # runs only if ExecStart succeeded ExecStartPost=/usr/bin/curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/<your-token>
Check the calendar spec with systemd-analyze calendar "*-*~01 23:00:00", then systemctl enable --now my-job.timer. Persistent=true runs a missed job at boot. Convert this schedule to Quartz or AWS cron() →
apiVersion: batch/v1
kind: CronJob
metadata:
name: my-job
spec:
schedule: "0 23 28-31 * *"
timeZone: "Etc/UTC" # Kubernetes 1.27+; otherwise the controller's timezone
concurrencyPolicy: Forbid # don't start a new run while one is active
startingDeadlineSeconds: 300 # still start if the controller was briefly down
jobTemplate:
spec:
backoffLimit: 2
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: your-image:tag
command: ["/bin/sh", "-c", "if [ \"$(date -d tomorrow +%d)\" = 01 ]; then /app/run-job.sh; fi && curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/<your-token>"]
on:
schedule:
- cron: "0 23 28-31 * *" # UTC unless you add timezone: under it
workflow_dispatch: {} # lets you run it by hand too
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: "if [ \"$(date -d tomorrow +%d)\" = 01 ]; then ./run-job.sh; fi"
- name: Tell Vigil the job ran
if: success()
run: curl -fsS -m 10 --retry 3 -o /dev/null https://puzaricloud.in/ping/${{ secrets.VIGIL_PING_TOKEN }}
GitHub reads schedules in UTC unless the entry sets timezone: (an IANA name), can delay them at busy times, and disables scheduled workflows in public repos after 60 days without activity.
Common mistakes
timedatectl or date. cronie (RHEL, Fedora, Arch) accepts CRON_TZ=Asia/Kolkata at the top of a crontab; Debian/Ubuntu cron does not.0 0 13 * 5 runs on every 13th and every Friday, not only on Friday the 13th.% is turned into a newline (everything after it goes to the command's stdin). Write date +\%F, not date +%F.PATH (often just /usr/bin:/bin), no login shell and no .bashrc. Use absolute paths and set variables at the top of the crontab.How to get alerted when it doesn't run
A cron job that stops running looks exactly like one that's working: no errors, no output. The reliable fix is a heartbeat (dead man's switch): the job pings a URL each time it finishes, and the monitor alerts you when a ping is late.
- Create a heartbeat in Vigil and choose cron schedule: 0 23 28-31 * *, timezone of your server.
- Set a grace period of about 60 minutes: long enough for a normal run to finish, short enough that you hear about it quickly.
- Add the ping to the end of the command (above). && means only successful runs ping; use /ping/<token>/$? to report the exit code, and /start to catch jobs that hang.
With the native systemd timer the ping only arrives on the last day itself, so give that heartbeat a fixed period of 31 days and a 1-day grace instead of the cron expression.
Watch this schedule — get alerted if it doesn't run
More: how to monitor cron jobs (exit codes, run time, logs) · heartbeat monitoring, explained
Vigil tells you when a run is missed
Vigil heartbeats understand cron expressions and timezones, so they know exactly when each run is due. Missed, failed or stuck runs alert you on email, Slack, Telegram, Discord or a webhook, and the history shows every run's duration.