- What is a cron expression?
- A cron expression is a string of five fields separated by spaces that defines a recurring schedule for a cron job — a task run automatically by the system at set intervals. The five fields represent, in order: minute (0–59), hour (0–23), day of month (1–31), month (1–12), and day of week (0–7, where both 0 and 7 are Sunday). Each field accepts a specific value, a wildcard (
*), a range (1-5), a list (1,3,5), or a step (*/15). Cron was introduced in Unix in the 1970s and remains the standard scheduling mechanism on Linux, macOS, and cloud platforms including GitHub Actions and AWS EventBridge. The cron daemon reads a crontab file and spawns the specified command whenever the current time matches the expression.
- What does
* * * * * mean? - The expression
* * * * * means "every minute of every hour of every day of every month on every day of the week." Each asterisk is a wildcard that matches all valid values for its field. In practice this schedule fires 1,440 times per day — once per minute — making it useful only for high-frequency health checks or demo purposes. Because it triggers so often it is rarely appropriate for database backups, report generation, or any task that takes more than a few seconds to complete. If you need a job every minute but only during business hours you would write * 9-17 * * 1-5, replacing the second and fifth wildcards with a range and list respectively.
- What does
*/5 mean in a cron expression? - The
*/5 syntax is a step value. In the minute field it means "at every 5th minute": 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55. The general form is */n, where n is the step size relative to the start of the field's range. In the minute field */10 fires at 0, 10, 20, 30, 40, 50. In the hour field */6 fires at 00:00, 06:00, 12:00, and 18:00. You can also combine a range with a step: 10-50/10 in the minute field fires at minutes 10, 20, 30, 40, and 50. Step values work in all five standard cron fields and are supported by Linux crontab, macOS cron, GitHub Actions, and most scheduling systems.
- What is the difference between
0 0 * * 0 and @weekly? 0 0 * * 0 and @weekly are functionally identical on most cron implementations: both run once a week at midnight on Sunday (00:00 Sunday). The @weekly nickname — along with @daily, @hourly, @monthly, and @yearly — is a convenience alias supported by Vixie cron (the standard on most Linux distributions) and by GitHub Actions. However, these aliases are not part of the POSIX cron standard and are not recognised by some minimal implementations such as BusyBox cron, AWS EventBridge, or Quartz Scheduler. For maximum portability always use the explicit five-field expression 0 0 * * 0 rather than the alias.
- How do I run a cron job every 30 minutes?
- Use the expression
*/30 * * * * to run a job every 30 minutes. This fires at minute 0 and minute 30 of every hour, every day. The step syntax */30 means "every 30th minute starting from 0", so it triggers at :00 and :30. If you want to offset the start — for example at :15 and :45 — use the list form 15,45 * * * * instead of a step. Some schedulers such as AWS EventBridge do not support */30 in the minute field for intervals that do not evenly divide 60; in those cases use the explicit list. For jobs that must run exactly every 30 minutes regardless of execution time, consider a persistent process with a sleep loop rather than cron, since cron does not account for job duration.
- How do I schedule a cron job on the last day of the month?
- On Linux crontab and macOS cron there is no built-in "last day of month" token; the workaround is to check inside the job script whether tomorrow is the 1st: schedule
0 23 28-31 * * and add a guard [ $(date -d tomorrow +%d) -eq 1 ] && /path/to/script.sh. On Quartz Scheduler and AWS EventBridge Scheduler, the special character L in the day-of-month field means "last day": 0 0 L * ? in Quartz or cron(0 0 L * ? *) in EventBridge. GitHub Actions does not support L. If your workload runs on a cloud scheduler that supports L, that is the cleanest solution. For raw Linux cron the script-based workaround is the only portable approach.
- What timezone do cron jobs run in?
- By default, cron jobs run in the system timezone of the host machine. On most Linux servers this is UTC, but it depends entirely on how the OS is configured. GitHub Actions cron schedules always run in UTC, regardless of repository or runner settings. AWS EventBridge Scheduler lets you specify a timezone per schedule (defaulting to UTC). Kubernetes CronJob resources default to the cluster's timezone; Kubernetes 1.25+ added a
timeZone field to override per job. To confirm the timezone your cron daemon uses, run crontab -l and check for a CRON_TZ or TZ variable at the top of the file — Vixie cron honours CRON_TZ=America/New_York set as an environment variable within the crontab.
- What is the difference between cron and crontab?
- Cron is the daemon — the background service that continuously checks scheduled tasks and runs them at the right time. Crontab (short for "cron table") is the configuration file that lists the jobs cron should run, one expression-plus-command per line. Each user on a Unix system can have their own crontab file, edited with the
crontab -e command and stored in /var/spool/cron/crontabs/. The system also has a /etc/cron.d/ directory for system-wide jobs. The word "crontab" is therefore used in two senses: the file format and the command-line utility used to manage that file. The cron daemon itself requires no configuration — it simply reads all crontabs and fires matching commands. - How do I test a cron expression without waiting?
- The fastest approach is to use an online cron expression parser such as DevFormatter's Cron Generator, which shows the next 10 scheduled times instantly. Command-line tools include
cronitor validate and the Python library croniter (pip install croniter), which can list upcoming fire times programmatically. For end-to-end testing on Linux, temporarily edit the crontab to trigger every minute (* * * * *) while your script writes a timestamp to a log file, then restore the real schedule once confirmed. On macOS, launchd job agents can be tested with launchctl start com.example.yourjob. AWS EventBridge provides a "Next 10 trigger dates" preview in the console. Never rely solely on the expression parser — always verify that the actual command runs successfully in the target environment.
- Are cron expressions the same in AWS EventBridge and Linux cron?
- No. AWS EventBridge Scheduler uses a six-field cron syntax wrapped in
cron(...): the first field is seconds (0–59), making the full format cron(seconds minutes hours day-of-month month day-of-week year). Linux crontab uses five fields with no seconds field and no year field. EventBridge also requires that exactly one of day-of-month or day-of-week be ? (not both wildcards at the same time), which is not a Linux cron rule. The L (last) and # (nth weekday) special characters are supported in EventBridge but not in standard Linux crontab. This means you cannot copy a Linux cron expression directly into EventBridge without adjusting the field count and ? placement. Always consult the AWS EventBridge Scheduler documentation when migrating schedules between platforms.