How do you run a cron job on the first of every month?

By TechCompare · Updated · How we check

0 0 1 * * is correct for first-of-month execution. For last-day-of-month scheduling, use a wrapper script or switch to systemd timers. If you need the 15th, 20th, or any day that exists in every month, the standard day-of-month field works without caveats.

Calculator

Next runs of 0 0 1 * *

Example from Mon, Nov 9, 2026 at 8:00 AM.

  1. Tue, Dec 1, 2026 at 12:00 AM
  2. Fri, Jan 1, 2027 at 12:00 AM
  3. Mon, Feb 1, 2027 at 12:00 AM
  4. Mon, Mar 1, 2027 at 12:00 AM
  5. Thu, Apr 1, 2027 at 12:00 AM

0 0 1 * * runs a job at midnight on the first day of every month. The third field (1-31) controls the day of the month.

Schedule pattern
Monthly schedule
monthly
Category
Common Patterns
Standard cron expression patterns

How this is calculated

Not every month has 31 days. If you specify the 31st, the job simply won't run in February, April, June, September, or November.

For the last day of the month, cron alone can't express it. The common workaround is to run on the 28th-31st and have the script check if tomorrow is the 1st. Alternatively, use 0 0 28-31 * * and let the script exit early if the date isn't the last day.

On systemd versions that support the last-day token, OnCalendar=*-*~01 00:00:00 can express the last day directly.

Verdict

Use 0 0 1 * * for the first of the month, and avoid the 31st, which silently skips February, April, June, September, and November. For last-day runs, standard cron needs 28-31 plus a script guard that checks if tomorrow is the 1st.

More Cron scenarios

Every 5 minutes
Running a cron job every 5 minutes uses the step operator in the minute field: */5 * * * *.
View details
Every hour
To run a job at the top of every hour, use 0 * * * *.
View details
Daily at midnight
0 0 * * * runs a job at exactly midnight (00:00) every day.
View details

Frequently asked questions

How do I run a cron job on the first of every month?
Use 0 0 1 * *. The third field is the day of month, and pinning it to 1 runs the job at midnight on the 1st of every month, every month. Monthly billing runs, usage reports, and archival jobs that process the previous month's data are the classic fits.
What happens if I schedule a cron job for the 31st of the month?
It silently skips months that don't have 31 days: February, April, June, September, and November. Cron doesn't warn you. The job simply never fires those months, which makes the 31st a trap for anything you expect to run reliably. Stick to days 1-28 for schedules that must run every month.
How do I run a cron job on the last day of the month?
Standard cron can't express it. The common workaround is 0 0 28-31 * * combined with a script that checks whether tomorrow is the 1st and exits early if it isn't. On systemd versions that support the last-day calendar token, use OnCalendar=*-*~01 00:00:00.