Cron expression generator

Pick a preset or type a crontab line. The tool explains each of the five fields, says when the job runs in plain words and lists its next runs, so you can check a schedule before it goes on a server.

Common schedules
Edit each field
When it runs Every 15 minutes, every day.

Cron jobs need a server that is always on. A small VPS runs backups, reports and scripts around the clock. From €3.02 a month today, among 2,226 servers.

Your crontab line

On the server, run crontab -e, paste the line with your own command, and save. crontab -l lists the jobs you have.

crontab -e
*/15 * * * * /path/to/script.sh >> /var/log/job.log 2>&1
FieldValueMatches
Minute*/150, 15, 30 and 45
Hour*every value
Day of month*every value
Month*every value
Day of week*every value

Works in your browser: nothing you type is sent anywhere.

How it is calculated

A crontab line starts with five fields separated by spaces, followed by the command to run. Cron checks them every minute and runs the command when the minute, hour, day of the month, month and day of the week all match.

┌─ Minute
│ ┌─ Hour
│ │ ┌─ Day of month
│ │ │ ┌─ Month
│ │ │ │ ┌─ Day of week
* * * * * /path/to/command

The two day fields combine in a way that surprises many people: when both are restricted, the job runs when either one matches. 0 0 13 * 5 runs on every 13th and on every Friday, not only on Friday the 13th. When one of the two starts with *, both have to match.

The five fields

FieldAllowed values
Minute0–59
Hour0–23
Day of month1–31
Month1–12 or JAN–DEC
Day of week0–7 or SUN–SAT (0 and 7 are Sunday)

Special characters

  • * matches every value of the field.
  • , lists values: 1,15 is the 1st and the 15th.
  • - is a range: 1-5 is Monday to Friday in the day-of-week field.
  • / is a step: */10 is every tenth value, 5/10 is every tenth from 5, 9-17/2 every second hour from 9 to 17.
  • @hourly, @daily, @weekly, @monthly and @yearly replace all five fields; @reboot runs once when the server starts.

Example

30 2 * * 1-5 runs at 02:30 from Monday to Friday: minute 30, hour 2, any day of the month, any month, and days of the week 1 to 5. Written as 30 2 * * 1-5 /usr/local/bin/backup.sh in the crontab, it starts a backup every working night.

Questions

What does */5 mean in cron?

Every fifth value of the field. In the minute field, */5 runs the job at minute 0, 5, 10 and so on up to 55: every five minutes. */15 is every quarter of an hour, and */2 in the hour field is every second hour from midnight.

How do I add a cron job on a Linux server?

Run crontab -e as the user the job should run as, add one line with the five fields and the command, then save and close the editor. crontab -l shows the jobs, and system-wide jobs go into a file in /etc/cron.d with the user name after the five fields.

Which time zone does cron use?

The server's own, usually UTC on a VPS. 0 3 * * * on a UTC server runs at 04:00 in Berlin in winter and 05:00 in summer. Some crons, such as cronie, accept a CRON_TZ= line above the jobs; otherwise convert the time yourself.

Should I use cron or a systemd timer?

Cron is simpler and works everywhere. A systemd timer needs two small files but logs every run in the journal, can catch up on runs missed while the server was off (Persistent=true), and stops two copies of the same job from running at once.