About the Cron Expression Generator
Cron expressions schedule backups, reports and maintenance jobs on servers, but the five-field syntax is easy to misread: is 0 2 * * 1 every Monday at 2 am, or something else? This cron generator works both ways. Choose minutes, hours, days and months from simple controls to build an expression, or paste one you inherited to see it described in plain English with its next run times. That makes it much harder to schedule a job for the wrong day or to forget that the server runs on UTC. It helps developers, system administrators and anyone automating tasks with hosting control panels. For timestamps in logs, use the Timestamp Converter, and for time zone checks, the Time Zone Converter.
Reading an existing expression is the direction most people need. Cron packs a schedule into five fields of terse punctuation, and a single character separates a job that fires four times an hour from one that fires only at quarter past. Listing the next five times the job will fire turns that guesswork into something you can simply check.
Standard cron syntax is supported in full: comma lists, hyphen ranges, slash steps and asterisks in every field, along with named shortcuts such as @daily and @weekly. The tool also points out the rule that surprises almost everyone: if you restrict both the day of the month and the day of the week, cron runs the job when either condition is met, not only when both are.
How to use the Cron Expression Generator
- Describe the scheduleStart from a preset or set the minute, hour, day, month and weekday fields yourself.
- Or paste an expressionIts meaning and its next run times are shown straight away.
- Check the plain-English summaryEach field is explained in ordinary words.
- Copy the expressionIt is ready to paste into a crontab, a hosting panel or a scheduler.
Cron Expression Generator features
- Expressions built from simple form controls
- Existing expressions explained in plain English
- The next five run times worked out
- Comma lists, hyphen ranges, slash intervals and asterisks accepted everywhere
- Shortcuts such as @daily and @hourly
- Ready-made presets for everyday schedules
- An alert when both calendar-day and weekday fields are restricted
- Field-by-field validation with specific messages
Common uses
- Scheduling a nightly backup or a weekly report
- Working out what an inherited cron line actually does
- Confirming exactly when a job will next run
- Turning a schedule described in words into cron syntax
- Explaining cron fields to a new team member
Cron jobs in practice: nightly backups, server time zones, the percent sign trap, overlapping runs and logging
Cron runs scheduled tasks on servers: backups, reports, clean-ups, reminders and data imports. Writing the expression is only half the job, because most cron failures come from the environment the job runs in rather than the schedule itself. This guide works through scheduling a nightly backup, lists everyday schedules and explains the traps that make jobs silently fail, run twice or never run at all.
A worked example: a nightly backup
A shop wants its database backed up at 2:30 am Pakistan time, when traffic is lowest. If the server's clock is set to Pakistan Standard Time, the expression is 30 2 * * *. Many servers run on UTC, however, and Pakistan is five hours ahead of UTC with no daylight saving, so 2:30 am in Pakistan is 9:30 pm UTC on the previous evening, written as 30 21 * * *. Checking the server's time zone before writing the expression avoids backups that run in the middle of the busiest hours.
Everyday schedules
- Every 15 minutes:
*/15 * * * *. - Weekdays at 9 am:
0 9 * * 1-5. - Every Sunday at 3 am:
0 3 * * 0. - First day of every month at midnight:
0 0 1 * *. - Every six hours:
0 */6 * * *.
Each of these is worth pasting back into the generator to read the plain-English description and next run times, which confirms the expression does what you meant.
The last day of the month
Standard cron has no symbol for the last day of the month. A common workaround runs the job at 11 pm on days 28 to 31 and lets the command check whether tomorrow is the first, running the real work only then. Some cron implementations and cloud schedulers add an L symbol for this, but it is not part of standard cron, so check before relying on it.
The percent sign trap
In a crontab file, the percent sign has a special meaning: it ends the command and starts the input passed to it. A command containing a date format such as date +%d therefore breaks mysteriously in cron while working perfectly in a terminal. Each percent sign must be escaped with a backslash, as \%, or the command moved into a script file where no escaping is needed.
A different environment
Cron jobs run with a minimal environment: a short PATH, no user profile and often a different shell. A command that works when you type it may fail in cron because a program cannot be found. Using full paths to programs and files, or setting PATH at the top of the crontab, solves most "works by hand, fails in cron" problems.
Overlapping runs
If a job takes longer than its interval, a second copy starts before the first finishes, which can corrupt imports or overload the server. Wrapping the command with a lock, for example using flock -n /tmp/import.lock before the command, makes a new run exit immediately while the previous one is still working.
Logging output
By default, cron emails any output to the account owner or discards it if mail is not configured, so errors vanish. Redirecting output to a log file, such as appending >> /var/log/backup.log 2>&1 to the command, keeps a record of every run and every error. Checking that log after the first scheduled run confirms the job really works.
Spreading the load
Many people schedule jobs at the top of the hour, so shared servers and external services see sudden spikes at minute 0. Choosing a less common minute, such as 17 or 43, spreads the load and reduces the chance of rate limits and timeouts when calling other services.
Daylight saving on foreign servers
Pakistan does not use daylight saving time, but servers set to European or North American time zones do. On the night the clocks change, a job scheduled between 1 am and 3 am may run twice or not at all. Running servers on UTC, and converting schedules from local time, avoids this twice-yearly surprise.
Common mistakes
- Writing schedules without checking the server's time zone.
- Using unescaped percent signs in crontab commands.
- Relying on PATH and profile settings that cron does not load.
- Discarding output, so failures go unnoticed.
Related tools
To convert schedule times between zones, use Time Zone Converter. To read timestamps in logs, try Timestamp Converter, and to set script permissions, Chmod Calculator.
Testing before scheduling
Run the exact command first as the same user that cron will use, for example the web server's user, because file permissions often differ from your own account. Then schedule it a few minutes ahead and watch the log during that first run. Only after it succeeds should you switch to the real schedule, so you are not waiting until 2:30 am to learn it fails.
Hosting control panels
Hosting control panels provide cron screens that write the same five-field expressions behind a simple form. They usually run each job as the website's own user, so the script and the files it touches need matching permissions. Adding a short comment describing each job's purpose helps anyone who inherits the server understand why it exists.
Privacy
Expressions are generated and explained in your browser. Nothing is sent to a server.
Frequently asked questions
What do the five cron fields stand for?
In order: minute, hour, day of the month, month and day of the week. Each one can hold a single number, a comma-separated list, a range such as 1-5, a step written with a slash, or an asterisk for every value.
What is the trap with day of month and day of week?
When both fields are restricted, cron runs the job if either one matches, not only when both do. An expression aimed at Mondays that fall on the 1st actually runs on every Monday and on every 1st of the month.
How does the slash step work?
A slash sets a repeating interval. In the minute field, */15 runs the job every fifteen minutes from the top of the hour, while a plain 15 runs it only once an hour, at quarter past.
Which time zone does a cron job use?
The server's local time, unless the crontab sets a time zone variable. That is a common reason for jobs running an hour off after a clock change, or running twice or not at all on the changeover night.
Can cron schedule to the second?
Classic cron has no seconds field. Some schedulers, such as Quartz and certain cloud services, put an extra seconds field in front of the usual five, but this tool works with the standard five-field format.
What do shortcuts like @daily and @reboot do?
They replace common patterns: @daily means midnight every day and @hourly means the start of every hour. @reboot is different, running a command once when the machine starts rather than on a repeating schedule.