Cron Job Expression Builder Visual Builder with Timezone + Kubernetes YAML Generator

Build, validate, and understand cron expressions. Generate Kubernetes CronJob YAML, AWS EventBridge format, and Linux crontab lines with next-run previews.

Every minutes
to
Every hours
to
to
to
to
MIN HOUR DOM MON DOW
Cron Expression
* * * * *
Every minute

Next 5 Run Times

Invalid expression — unable to calculate run times.

Common Presets

Generated Output

Standard Cron Expression
Linux crontab Line
#
Kubernetes CronJob YAML

        
AWS EventBridge / CloudWatch Events
# EventBridge cron (adds year field, ? for unspecified)
Docker — cron via host crontab
# Run in Docker container on schedule

Frequently Asked Questions

What is cron syntax and how do the five fields work?

A standard cron expression has five space-separated fields: 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 represent Sunday). Each field accepts a specific value, a wildcard (*), a range (1-5), a list (1,3,5), or a step value (*/15 means every 15 units). Example: "30 9 * * 1-5" means 9:30 AM every weekday.

What does "*/5" mean in cron?

"*/5" is a step expression meaning "every 5 units". In the minute field, */5 means every 5 minutes (0, 5, 10, 15...). In the hour field, */2 means every 2 hours. Steps work in any field and can be combined: "0-30/5" means every 5 minutes within the first 30 minutes of each hour. This is one of the most commonly used cron features for periodic tasks.

How do timezones work in cron jobs?

Traditional Linux cron runs in the system timezone (set in /etc/localtime or TZ environment variable). If your server is in UTC but your users are in IST (+5:30), a cron at "0 9 * * *" triggers at 9 AM UTC, which is 2:30 PM IST. Always verify your server timezone with "date" or "timedatectl". Modern platforms like Kubernetes CronJobs, AWS EventBridge, and Cloud Scheduler allow you to specify a timezone explicitly in the job configuration.

How do I schedule a cron job in Kubernetes?

Kubernetes CronJobs use the standard 5-field cron syntax in a CronJob manifest. Key fields: spec.schedule (the cron expression), spec.jobTemplate (the Pod template to run), spec.timeZone (explicit timezone support added in Kubernetes 1.27+), spec.concurrencyPolicy (Forbid/Allow/Replace to control overlapping runs), and spec.startingDeadlineSeconds (how late a missed run can start). Apply with kubectl apply -f cronjob.yaml.

What is the difference between cron and AWS EventBridge scheduler?

AWS EventBridge Scheduler supports both cron expressions and rate expressions. Its cron syntax adds a 6th field for year: "cron(minutes hours day-of-month month day-of-week year)". Important difference: EventBridge does NOT support both day-of-month and day-of-week simultaneously — one must be "?". EventBridge also natively supports timezones in the schedule configuration, unlike traditional cron which depends on the system timezone.

How do I prevent overlapping cron job runs?

Several approaches: (1) In Linux crontab, use flock: "* * * * * flock -n /tmp/myjob.lock /path/to/script.sh". (2) In Kubernetes, set spec.concurrencyPolicy: Forbid to skip new runs if the previous is still running. (3) For distributed systems, use a database advisory lock or Redis SETNX to acquire a lock before running. (4) In AWS EventBridge, configure the target with a "Flexible time window" and set concurrency limits on the Lambda or ECS target.

What does "L" and "W" mean in cron (Quartz scheduler)?

"L" and "W" are non-standard extensions used in Quartz Scheduler (Java) and some enterprise schedulers, not in standard Linux cron. "L" in the day-of-month field means "last day of the month" (e.g., "L" = last day, "L-3" = 3 days before end of month). "W" means "nearest weekday" (e.g., "15W" = nearest weekday to the 15th). "LW" means "last weekday of the month". These are not supported in standard Unix cron, Kubernetes, or AWS EventBridge.

How do I run a cron job inside a Docker container?

Three common approaches: (1) Install cron in the container image (e.g., apt-get install cron) and add a crontab file — not recommended for production as it adds complexity. (2) Use Docker's built-in restart policy with a simple sleep loop in the ENTRYPOINT — simple but imprecise. (3) Run cron outside the container using docker exec or docker run on a schedule — the cleanest approach for containerized environments. For production, prefer Kubernetes CronJobs or a purpose-built scheduler.

What is a good alternative to cron for modern applications?

Modern alternatives: (1) Kubernetes CronJobs — cloud-native, timezone-aware, with retry policies. (2) AWS EventBridge Scheduler — serverless, timezone-native, integrates with 200+ AWS services. (3) Google Cloud Scheduler — fully managed, HTTP/Pub-Sub targets. (4) Celery Beat (Python) — application-level scheduling with a database backend. (5) BullMQ or Agenda (Node.js) — Redis-backed schedulers with rich retry and priority support. (6) Temporal — workflow orchestration with durable scheduling and complex dependency chains.

Why did my cron job not run at the expected time?

Common causes: (1) Timezone mismatch — cron runs in the server timezone, not your local timezone. (2) The cron daemon is not running (check with "systemctl status cron"). (3) Permission issues — the user running cron may lack execute permission on the script. (4) Environment differences — cron runs with a minimal PATH; use absolute paths for all commands. (5) Output not redirected — errors may be silently swallowed; add ">> /var/log/myjob.log 2>&1" to capture output. (6) Missed run — if the server was down when the cron was scheduled, the job is skipped (use "catchup: true" in Kubernetes or similar).

Understanding Cron Jobs: A Complete Guide

Cron is one of the most foundational tools in Unix and Linux system administration. Named after the Greek word for time (Chronos), cron is a time-based job scheduler that executes commands or scripts at specified intervals. From running nightly database backups to sending scheduled email reports, cron handles the automated scheduling layer for millions of production systems worldwide.

The cron daemon (crond) runs continuously in the background, checking every minute whether any scheduled jobs need to run. Job schedules are stored in a crontab (cron table) — a configuration file where each line defines one scheduled task. Users manage their own crontabs with the crontab -e command, while system-wide jobs live in /etc/cron.d/, /etc/cron.daily/, /etc/cron.hourly/, and related directories.

Cron Expression Syntax Deep Dive

A standard cron expression consists of five fields separated by spaces, each controlling a different time dimension:

  • Minute (0–59): When within the hour the job runs. 0 = on the hour, */15 = every 15 minutes, 30 = at the half hour.
  • Hour (0–23): The 24-hour clock hour. 0 = midnight, 9 = 9 AM, */2 = every 2 hours.
  • Day of Month (1–31): Calendar day of the month. 1 = 1st of month, 15 = 15th, * = every day.
  • Month (1–12): Calendar month. 1 = January, 12 = December. Some cron implementations also accept month names (JAN, FEB, etc.).
  • Day of Week (0–7): Day of the week, with both 0 and 7 representing Sunday. 1 = Monday, 5 = Friday, 1-5 = weekdays.

Special characters expand the expressiveness of cron syntax: * (any value), , (list separator — "1,3,5"), - (range — "1-5"), and / (step — "*/15"). The combination of these operators covers virtually every scheduling pattern needed in practice.

Kubernetes CronJobs: Cloud-Native Scheduling

Kubernetes introduced the CronJob resource as a first-class scheduling primitive for containerized workloads. Unlike traditional cron, which relies on a single host's cron daemon, Kubernetes CronJobs run within the cluster's control plane and benefit from all of Kubernetes' orchestration features: container isolation, resource limits, retry policies, distributed scheduling, and declarative configuration.

Key Kubernetes CronJob features include concurrencyPolicy (control whether overlapping runs are allowed, forbidden, or whether old runs are replaced), startingDeadlineSeconds (how long past the scheduled time a missed job can still start), successfulJobsHistoryLimit and failedJobsHistoryLimit (how many completed jobs to retain for debugging), and spec.timeZone (native timezone support since Kubernetes 1.27, eliminating the need to convert all schedules to UTC).

A well-structured Kubernetes CronJob manifest specifies resource requests and limits on the job container, sets an appropriate restartPolicy (OnFailure for jobs that should retry, Never for jobs that must run exactly once), and includes appropriate liveness probes if the job runs longer than expected. Always test CronJob schedules in a staging cluster before deploying to production.

AWS EventBridge Scheduler: Serverless Cron at Scale

AWS EventBridge Scheduler (formerly CloudWatch Events) provides a fully managed, serverless scheduling service. It executes schedules without requiring you to provision or manage cron infrastructure. EventBridge Scheduler supports three schedule types: cron-based schedules (using a 6-field cron expression with an added year field), rate-based schedules ("rate(5 minutes)", "rate(1 day)"), and one-time schedules (run once at a specific datetime).

EventBridge Scheduler's cron syntax differs from standard cron in two important ways: it uses a 6-field expression (minute, hour, day-of-month, month, day-of-week, year), and it requires that either day-of-month or day-of-week be set to ? (meaning "not specified") — you cannot specify both simultaneously. EventBridge also supports native timezone configuration at the schedule level, making it far easier to manage schedules for multi-timezone applications than traditional cron.

Best Practices for Production Cron Jobs

Idempotency is the most important property of a well-designed cron job. An idempotent job produces the same result whether it runs once or multiple times — it's safe to retry on failure. Design jobs to be idempotent by default: check whether work has already been done before doing it, use database transactions with unique constraints, and avoid side effects that can't be rolled back.

Observability: Always capture job output. Add >> /var/log/jobname.log 2>&1 to crontab entries to capture both stdout and stderr. For production systems, emit structured logs (JSON) to a centralized log aggregator (CloudWatch Logs, Datadog, Elastic). Emit metrics on job start, duration, success, and failure. Set up alerts on job failure or when jobs take longer than expected.

Overlap prevention: If a cron job can run longer than its schedule interval, it may overlap with the next invocation. Use file-based locking (flock), database advisory locks, or Redis SETNX to ensure only one instance runs at a time. In Kubernetes, set concurrencyPolicy: Forbid. In distributed systems, use a leader-election mechanism or a purpose-built distributed scheduler like Celery Beat with a database backend.

Environment isolation: Cron runs with a minimal shell environment — PATH typically includes only /usr/bin:/bin. Always use absolute paths for commands in crontab entries. Source the full environment if needed: source /etc/environment or use a wrapper script that sets up the environment before running the actual job. For secrets, use environment variables injected at runtime via a secrets manager rather than hardcoded values in the crontab.

Cron Field Reference

Minute 0–59
Hour 0–23
Day of Month 1–31
Month 1–12
Day of Week 0–7 (Sun=0,7)
Special Characters
* Any / every
, List: 1,3,5
- Range: 1-5
/ Step: */15

Expression Examples

* * * * * Every minute
0 * * * * Every hour
0 0 * * * Daily midnight
0 9 * * 1-5 Weekdays 9am
0 0 1 * * Monthly 1st
*/15 * * * * Every 15 min
0 */6 * * * Every 6 hours
30 9 * * 1 Monday 9:30am

Related Tools

AI Token Counter — Claude, GPT-4o, Gemini
Count tokens and estimate API costs for Claude 3.5 Sonnet, GPT-4o, and Gemini 1.5 Pro. Multi-model comparison with optimization tips. Updated with latest pricing.
Use Tool →

Deploy your cron jobs on DigitalOcean ($200 credit)

Get $200 Credit →

User Reviews

Loading reviews…

Write a Review

Reviews are moderated and published within 24 hours.

Send Feedback

Found a bug? Wrong result? Have a suggestion? We read every message.