Skip to main content
General

Cron Expression Guide — Examples & Generator 2026

5 min read

Up-to-date Feed

View All
General

XML Sitemap Best Practices — Complete 2026 Guide

Read Now
General

What is a Unified Diff? The Complete Technical Guide (2026)

Read Now
General

What is Base64 Encoding? How to Decode Safely

Read Now
General

What is JSON: Complete Guide to RFC 8259

Read Now
General

What is JWT? A Complete Guide to JSON Web Tokens & Security (2026)

Read Now
General

Web Tools 2.0: The Evolution of Modern Developer Utilities

Read Now
General

JSON Validator vs JSON Formatter: Why is my JSON Invalid? (2026)

Read Now
General

WCAG Color Contrast Requirements (2026 Developer Guide)

Read Now
General

URL Slug SEO Best Practices 2026: Routing & Structure

Read Now
General

SSL Certificate Expired — How to Check and Fix 2026

Read Now
General

SQL Injection Testing for Beginners — Safe Local Guide 2026

Read Now
General

The Complete Meta Tags Guide: SEO & Open Graph (2026)

Read Now
General

The Ultimate Technical SEO Audit Checklist (2026 Guide)

Read Now
General

Robots.txt Guide 2026: Block AI Crawlers

Read Now
General

PX to REM Conversion Guide — CSS Accessibility 2026

Read Now
General

JS Regex Cheat Sheet: ECMA-262 Reference & Catastrophic Backtracking

Read Now
General

Optimizing Core Web Vitals for Enterprise Next.js Applications (2026)

Read Now
General

Privacy-First Web Development: Zero-Knowledge Client Tools (2026)

Read Now
General

Nginx Config Generator: Reverse Proxy Guide 2026

Read Now
General

Modern CSS Architecture for Enterprise: Component Scoping, Cascade Layers (@layer), and Tailwind Tokenization

Read Now
General

Kubernetes YAML Validator — Guide for 2026

Read Now
General

JWT vs Session Cookies (2026 Ultimate Architecture Guide)

Read Now
General

JWT Token Expiry Error Fix — Node.js 2026

Read Now
General

JSON to YAML Converter: Free Offline Tool 2026

Read Now
General

.htaccess Guide 2026: Security Hardening & Redirect Rules

Read Now
General

How to Use the Browser DevTools Network Tab Like a Pro

Read Now
General

How to Remove EXIF Data from Photos Online (2026 Tutorial)

Read Now
General

How Secure is My Password? Entropy & GPU Cracking Guide (2026)

Read Now
General

Gzip vs Brotli Compression: Web Performance Guide 2026

Read Now
General

Favicon Sizes in 2026: The Complete Asset Manual

Read Now

Home / Blog / Cron Expression Guide — Examples & Generator 2026

Cron Expression Guide — Examples & Generator 2026

A comprehensive breakdown of cron syntax to automate scripts, database backups, and Kubernetes jobs without error.

Published June 05, 2026 · Last updated June 14, 2026 · By Abu Sufyan, Full-stack Developer & DevOps Engineer


Quick Answer

A standard cron expression consists of 5 fields separated by spaces: Minute, Hour, Day-of-month, Month, and Day-of-week. By placing numbers, asterisks (*), hyphens (-), or slashes (/) in these fields, you can schedule scripts to run at highly specific intervals. For example, */5 * * * * triggers a job every 5 minutes, while 0 2 * * * runs a job every day at 2:00 AM.

👉 Try the Offline Cron Expression Generator → — visually build your schedule and instantly verify the next 5 execution times without reading man pages.


Why This Happens (In-Depth Analysis)

When developers struggle with cron, the issue rarely lies in the syntax itself; the failure usually stems from fundamental misunderstandings of server timezones and execution environments.

Early in my career, I deployed a massive database backup script using a cron job set to 0 2 * * * (2:00 AM daily). I explicitly wanted the backup to happen during the lowest traffic window for our US-based users to avoid locking the production tables. A week later, the database crashed at 9:00 PM EST due to severe IO exhaustion. Why? The AWS EC2 instance was running in UTC. 2:00 AM UTC is exactly 9:00 PM EST—smack in the middle of our platform's prime time.

The core lesson here is that a cron expression is just a dumb string of characters. It has absolutely no awareness of geography, daylight saving time (DST), or user intent. You must rigorously align your cron schedules to the server's local timezone configuration, which in modern 2026 cloud-native architecture should always be firmly locked to UTC.

Furthermore, cron tasks execute in a highly restricted, non-interactive shell. Developers frequently write a script that runs perfectly when they type ./script.sh in their terminal, but fails silently when triggered by cron. This happens because cron does not load your ~/.bashrc or ~/.profile. Environment variables like $PATH or $NODE_ENV are usually missing. If your script relies on /usr/local/bin/node, you must explicitly declare that absolute path within the script or at the top of your crontab file.


How to Fix It (Step-by-Step Tutorial)

To master cron scheduling and eliminate deployment anxiety, you need to understand the field structure and map out your schedule carefully. Here is exactly how to build and validate a standard 5-field cron expression.

1. Understand the 5-Field Syntax

A standard Vixie cron expression consists of five fields. (Note: Systems like AWS CloudWatch or Quartz Java use 6 fields to include seconds or years, but standard Linux and Kubernetes use 5).

* * * * *
│ │ │ │ │
│ │ │ │ └── Day of the week (0 - 7) (0 and 7 are Sunday)
│ │ │ └──── Month (1 - 12)
│ │ └────── Day of the month (1 - 31)
│ └──────── Hour (0 - 23)
└────────── Minute (0 - 59)

Special Characters to Master:

  • * (Asterisk): Matches all values. (e.g., * in the hour field means "every hour").
  • , (Comma): Separates items in a list. (e.g., 1,15 in the minute field means "at minute 1 and 15").
  • - (Hyphen): Defines a range. (e.g., 9-17 in the hour field means "between 9 AM and 17:00 / 5 PM").
  • / (Slash): Specifies step values/increments. (e.g., */10 in the minute field means "every 10 minutes").

2. Identify and Translate Your Schedule

Translate your human requirement into the 5 fields. Here are 20 heavily used examples you can copy directly into production:

High Frequency

  • Every minute: * * * * *
  • Every 5 minutes: */5 * * * *
  • Every 15 minutes: */15 * * * *
  • Every 30 minutes: */30 * * * *

Hourly Schedules

  • Every hour, precisely on the hour: 0 * * * *
  • Every 2 hours: 0 */2 * * *
  • At minute 15 past every hour: 15 * * * *

Daily Schedules

  • Midnight every day: 0 0 * * *
  • Every day at 2:30 AM: 30 2 * * *
  • Every day at 8:00 AM and 8:00 PM: 0 8,20 * * *

Weekly Schedules

  • Every Sunday at midnight: 0 0 * * 0
  • Every Monday at 9:00 AM: 0 9 * * 1
  • Monday through Friday at 5:00 PM (Business close): 0 17 * * 1-5
  • Weekends only, at noon: 0 12 * * 0,6

Monthly / Yearly Schedules

  • First day of every month at midnight: 0 0 1 * *
  • 15th of every month at 3:00 AM: 0 3 15 * *
  • January 1st at midnight (Happy New Year): 0 0 1 1 *

3. Implement in Kubernetes (CronJob Manifests)

If you are writing a Kubernetes CronJob manifest, the syntax is identical to Linux cron. However, Kubernetes adds a crucial execution parameter.

apiVersion: batch/v1
kind: CronJob
metadata:
  name: database-backup
spec:
  schedule: "0 2 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: backup
            image: backup-image
          restartPolicy: OnFailure

If your job takes 10 minutes to run, but your cron is scheduled every 5 minutes, Kubernetes will overlap the pods. Setting concurrencyPolicy: Forbid ensures that a new job will not start if the previous one is still executing.

Faster way: use the Cron Expression Generator

Stop risking production outages on a misunderstood syntax rule. You can visually build complex schedules using our dedicated tool.

Open the Cron Expression Generator — Free, No Signup →

The generator will translate human-readable inputs ("Every Tuesday at 4 AM") into flawless 5-field syntax and output the next 10 execution dates based on your local timezone, completely offline.


Edge Cases Most Guides Miss

The most dangerous, yet least documented, edge case in cron scheduling is The Day/Date OR Trap.

Suppose you want to run a financial audit script on the first of the month, but only if the first of the month is a Monday. A logical developer might write: 0 0 1 * 1

Unfortunately, in standard cron implementations, if both the Day-of-month (field 3) and Day-of-week (field 5) are specified, the cron daemon treats them as an OR operator, not an AND operator.

Therefore, 0 0 1 * 1 translates to: "Run at midnight on the first of the month, OR run at midnight every Monday." Your script will execute every single Monday, plus the 1st of every month, wreaking havoc on your financial reporting.

To solve this, you must schedule the job to run every Monday (0 0 * * 1), and inside your actual bash or Python script, write a conditional statement to check if today's date is the 1st. [ "$(date +\%d)" = "01" ] || exit 0.

Another massive edge case is daylight saving time (DST) transitions. If you schedule a job for 2:30 AM local time, what happens in Spring when the clock jumps from 1:59 AM to 3:00 AM? The job skips entirely. What happens in Autumn when 2:30 AM happens twice? The job runs twice. The only permanent fix is migrating the host operating system strictly to UTC.


Comprehensive FAQ

What does */5 * * * * mean?

It means the job will run every 5 minutes, at the 0, 5th, 10th, 15th (and so on) minute of every hour, every day.

How do I run a cron job every second?

Standard cron expressions only resolve down to the minute. You cannot run a job every second using standard Linux cron. You would need to write a custom daemon, use a Systemd timer, or write a bash script containing a while true; do ./script.sh; sleep 1; done loop.

Why is my cron script failing when it runs manually fine?

Cron executes jobs in a restricted environment where standard environment variables (like $PATH) are missing. Always use absolute paths (e.g., /usr/bin/python3 /var/scripts/task.py) and source your .bashrc explicitly inside the script if you need those variables.

Do cron jobs overlap if the previous run hasn't finished?

Yes. Linux cron will blindly start a new process at the scheduled time regardless of whether the last script is still running. You must use tools like flock (file locking) inside your script to prevent concurrent executions, or use Kubernetes concurrencyPolicy: Forbid.


About the Author

Abu Sufyan — Full-stack Developer and DevOps Engineer. Founder of WebToolkit Pro. Specializes in cloud-native architecture, Kubernetes deployments, and automated infrastructure pipelines. GitHub · Portfolio


Related tools:


{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Cron Expression Guide — Examples & Generator 2026",
  "description": "Master cron expression syntax with 20 ready-to-use examples. Learn how to handle timezones, Kubernetes scheduling, and debug complex CRON strings securely.",
  "datePublished": "2026-06-05",
  "dateModified": "2026-06-14",
  "author": {
    "@type": "Person",
    "name": "Abu Sufyan",
    "url": "https://github.com/abusufyan-netizen"
  },
  "publisher": {
    "@type": "Organization",
    "name": "WebToolkit Pro",
    "url": "https://wtkpro.site"
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://wtkpro.site/blog/cron-expression-guide-examples/"
  }
}
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "What does `*/5 * * * *` mean?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "It means the job will run every 5 minutes, at the 0, 5th, 10th, 15th (and so on) minute of every hour, every day."
      }
    },
    {
      "@type": "Question",
      "name": "How do I run a cron job every second?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Standard cron expressions only resolve down to the minute. You cannot run a job every second using standard Linux cron. You would need to write a custom daemon, use a Systemd timer, or write a bash script containing a sleep loop."
      }
    },
    {
      "@type": "Question",
      "name": "Why is my cron script failing when it runs manually fine?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Cron executes jobs in a restricted environment where standard environment variables (like $PATH) are missing. Always use absolute paths and source your .bashrc explicitly inside the script if you need those variables."
      }
    },
    {
      "@type": "Question",
      "name": "Do cron jobs overlap if the previous run hasn't finished?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Yes. Linux cron will blindly start a new process at the scheduled time regardless of whether the last script is still running. You must use tools like flock inside your script to prevent concurrent executions."
      }
    }
  ]
}
Try the toolInstant

Cron Expression Generator

Build cron schedules visually and get a plain-English description instantly.

100% client-side·No sign-up·No data sent
Open Tool Free

wtkpro.site

WP

WebToolkit Pro Team

Contributing Author

Blog & Journal Archive

All Entries →