Skip to content
Cron Cookbook

Run a job every hour

The cron expression for every hour is 0 * * * *. The 0 in the minute field fires at minute zero of every hour, 24 times a day. Leaving the minute as * would run it every minute instead.

crontab syntax · 5 fields
0****

Next 5 runs

Vercel always runs schedules in UTC, and GitHub Actions does unless you set a time zone. Crontab and Kubernetes use the server's time zone.

Field by field

0Minute
At minute 0
*Hour
Every hour, 0 to 23
*Day of month
Every day of the month
*Month
Every month
*Day of week
Every day of the week

By platform

Most schedulers take the same five fields. The wrapper, time zone and limits differ.

crontab -e
# m h  dom mon dow   command
0 * * * * /usr/local/bin/sync.sh >> /var/log/sync.log 2>&1

Runs in the server's local time zone

Cron starts jobs with a minimal environment: use absolute paths, and send output to a log so failures don't disappear.

Other hourly schedules

Change the minute to move the run off the top of the hour, or narrow the hour and weekday fields.

ExpressionRuns
30 * * * *Every hour at :30
0 9-17 * * *Every hour from 09:00 through 17:00
0 * * * 1-5Every hour, on the hour, Monday through Friday
@hourlySame as 0 * * * * in crontab and Kubernetes CronJobs; other schedulers need the five fields

Run a script every hour with /etc/cron.hourly

On Linux, root can skip the crontab line and put an executable script in /etc/cron.hourly. The system crontab runs every script in that directory once an hour with run-parts.

the system crontab
# Debian and Ubuntu: /etc/crontab, at minute 17
17 * * * * root cd / && run-parts --report /etc/cron.hourly

# Fedora, RHEL and other cronie systems: /etc/cron.d/0hourly, at minute 1
01 * * * * root run-parts /etc/cron.hourly
shell
# Install the script, executable and without a dot in its name
sudo install -m 755 backup /etc/cron.hourly/backup

# List the scripts run-parts will run, without running them
run-parts --test /etc/cron.hourly

On Debian and Ubuntu, run-parts skips any file whose name contains a dot, so /etc/cron.hourly/backup.sh never runs and nothing is logged. Names may use only letters, digits, underscores and hyphens. Leaving the dot out works on every distribution, and run-parts --test lists the scripts it would run.

Each script must be executable and start with a line such as #!/bin/sh. run-parts skips a file without the execute bit, and one without the #! line fails with “Exec format error”. The scripts run as root from /, one after another in name order, so a slow script delays the rest.

You don't choose the minute, and the scripts always run as root. To run at the top of the hour, or as another user, add 0 * * * * to that user's crontab with crontab -e instead.

Once a day at a set time

To run a job every day instead of every hour, fix the hour as well as the minute. The minute comes first: 30 4 * * * runs once a day at 04:30, and 0 0 * * * every day at midnight. Leave the last three fields as * for every day of every month.

ExpressionRuns
0 0 * * *Every day at midnight (00:00); @daily and @midnight are shortcuts for it in crontab
0 2 * * *Every day at 02:00
30 4 * * *Every day at 04:30
0 8 * * *Every day at 08:00
0 12 * * *Every day at noon
59 23 * * *Every day at 23:59, the last minute of the day
0 9,21 * * *Twice a day, at 09:00 and 21:00
0 8 * * 1-5At 08:00, Monday through Friday only

Two mistakes are common. Writing the hour first, as in 4 30 * * *, is rejected because 30 isn't an hour. Leaving the minute as *, as in * 2 * * *, runs the job every minute from 02:00 to 02:59, 60 times a day.

“Every day at 04:30” means 04:30 in the scheduler's time zone. Crontab uses the server's time zone, so check it with timedatectl. Kubernetes CronJobs use the controller's zone unless you set .spec.timeZone. GitHub Actions runs schedules in UTC unless you set timezone, and Vercel always uses UTC. On the Hobby plan, Vercel runs a daily job at some point within the hour you set.

Where clocks change for daylight saving time, 02:30 doesn't happen on the spring-forward day and 01:30 happens twice in the autumn. Debian's cron and cronie still run a daily job once on those days, but other schedulers may skip it or run it twice. Pick a time outside 01:00–03:00, or keep the server on UTC.