Run a cron job on the first of every month: 0 0 1 * * guide

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. This is the standard pattern for monthly billing runs, usage reports, and archival jobs that process the previous month's data.

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. Systemd timers handle this natively with OnCalendar=*-*-28..31 00:00:00 plus a script guard.

Verdict

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.

More Cron scenarios

Frequently asked questions

What is a Cron Job?
A cron job is a scheduled task that runs automatically on a Unix-like operating system (like Linux or macOS) at specific intervals. It is heavily used by developers to run background tasks like database backups, cache clearing, or sending nightly emails.
What do the 5 parts of a cron expression mean?
From left to right, the 5 fields are: Minute (0-59), Hour (0-23), Day of the Month (1-31), Month (1-12), and Day of the Week (0-6, where 0 and 7 are Sunday).
What does the asterisk (*) mean in Cron?
The asterisk acts as a wildcard, meaning 'every'. For example, if the minute field is an asterisk, the task runs every single minute. If the month field is an asterisk, the task runs every single month.
How do I run a task every 5 minutes?
To run a task every 5 minutes, use the slash operator in the minute field like this: */5 * * * *. The */5 means 'every 5th minute'.