CronViz - Free Online Cron Expression Generator and Scheduler Tool
Cron Expression Generator

Schedule tasks with Cron expressions

Frequently Asked Questions

Find quick answers to common questions about cron expressions, syntax, and scheduling.

Basics

What is a cron expression?

A cron expression is a string of 5 fields separated by spaces that defines when a scheduled task should run. The format is:

minute hour day-of-month month day-of-week

For example, 0 9 * * 1-5 means "At 9:00 AM, Monday through Friday".

Try our generator β†’

How do I read a cron expression?

Read a cron expression from left to right:

  1. Minute (0-59): Which minute of the hour
  2. Hour (0-23): Which hour of the day (24-hour format)
  3. Day of Month (1-31): Which day of the month
  4. Month (1-12): Which month
  5. Day of Week (0-6): Which day of week (0 = Sunday)

Example: 30 14 * * 2 = "At 2:30 PM every Tuesday"

What does the asterisk (*) mean in cron?

The asterisk (*) is a wildcard that means "every" or "any".

  • * * * * * = Every minute of every day
  • 0 * * * * = Every hour (at minute 0)
  • 0 0 * * * = Every day at midnight
  • 0 0 * * 0 = Every Sunday at midnight

It's the most commonly used special character in cron expressions.

What is the difference between cron and crontab?

Cron is the time-based job scheduler in Unix-like operating systems. It's the daemon (background process) that runs scheduled tasks.

Crontab (cron table) is the file that contains the list of cron jobs and their schedules. Each user can have their own crontab file.

Think of cron as the engine and crontab as the schedule/configuration.

How often does cron check for jobs?

Cron checks for jobs to run every minute. This is why the smallest time unit in a cron expression is one minute - you cannot schedule jobs to run every second with standard cron.

If you need sub-minute scheduling, you'll need to use alternative solutions like systemd timers or custom scripts.

Can I run a cron job every second?

No, standard cron does not support sub-minute scheduling. The minimum interval is one minute.

Workarounds:

  1. Run a script every minute that loops with sleep delays
  2. Use systemd timers (Linux) with OnUnitActiveSec
  3. Use a programming language scheduler like node-cron or APScheduler
  4. Use a task queue like Celery or RabbitMQ

Syntax & Special Characters

What do commas (,) mean in cron expressions?

Commas allow you to specify multiple values in a single field.

Examples:

  • 0 8,12,18 * * * = At 8 AM, 12 PM, and 6 PM
  • 0 0 * * 1,3,5 = At midnight on Monday, Wednesday, Friday
  • 0 9 1,15 * * = At 9 AM on the 1st and 15th of each month

What does the dash (-) mean in cron?

The dash specifies a range of values.

Examples:

  • 0 9-17 * * * = Every hour from 9 AM to 5 PM
  • 0 0 * * 1-5 = At midnight, Monday through Friday
  • */15 9-17 * * * = Every 15 minutes from 9 AM to 5 PM

Ranges are inclusive (both start and end are included).

What does the slash (/) mean in cron?

The slash specifies step values or "every Nth" interval.

Examples:

  • */5 * * * * = Every 5 minutes
  • 0 */2 * * * = Every 2 hours
  • */15 9-17 * * * = Every 15 minutes between 9 AM-5 PM
  • 0 0 */3 * * = Every 3 days at midnight

Format: start/step or */step

Can I use special strings like @daily?

Yes! Many cron implementations support special strings as shortcuts:

  • @yearly or @annually = 0 0 1 1 * (Jan 1 at midnight)
  • @monthly = 0 0 1 * * (1st of month at midnight)
  • @weekly = 0 0 * * 0 (Sunday at midnight)
  • @daily or @midnight = 0 0 * * *
  • @hourly = 0 * * * *
  • @reboot = Run once at startup

Note: Not all systems support these. Check your implementation.

What is the L character in cron?

The L character stands for "last" and is used in some cron implementations (like Quartz):

  • 0 0 L * * = Last day of the month
  • 0 0 * * 5L = Last Friday of the month
  • 0 0 L-3 * * = 3 days before the end of the month

Warning: Not supported in standard Unix cron! Mainly used in:

  • Java Quartz Scheduler
  • AWS EventBridge
  • Spring @Scheduled

Common Use Cases

How do I run a job every day at midnight?

Expression: 0 0 * * *

This means:

  • Minute: 0
  • Hour: 0 (midnight)
  • Day: * (every day)
  • Month: * (every month)
  • Day of week: * (any day)

See more daily schedule examples β†’

How do I run a job every 5 minutes?

Expression: */5 * * * *

This means:

  • Minute: */5 (every 5 minutes)
  • Hour: * (every hour)
  • Day: * (every day)
  • Month: * (every month)
  • Day of week: * (any day)

The job will run at: 00:00, 00:05, 00:10, 00:15, ..., 23:55

How do I run a job only on weekdays?

Expression: 0 9 * * 1-5

This runs at 9 AM, Monday through Friday.

Alternative: 0 9 * * MON-FRI (if your system supports day names)

Weekend only: 0 9 * * 0,6 or 0 9 * * SAT,SUN

Day of week values:

  • 0 or 7 = Sunday
  • 1 = Monday
  • ...
  • 6 = Saturday

How do I schedule a backup at 2 AM every day?

Expression: 0 2 * * *

This is a popular time for backups because:

  • Low system usage (most users offline)
  • Won't interfere with business hours
  • Enough time before work hours start

Example command:

0 2 * * * /usr/local/bin/backup-database.sh

How do I run a job on the first day of each month?

Expression: 0 0 1 * *

This runs at midnight on the 1st of every month.

Variations:

  • First Monday: 0 0 1-7 * 1
  • First weekday: 0 0 1-3 * 1-5
  • Last day of month: Requires script logic or advanced features

How do I run multiple jobs at the same time?

You have two options:

Option 1: Multiple crontab entries

0 9 * * * /path/to/job1.sh
0 9 * * * /path/to/job2.sh

Option 2: One entry with multiple commands

0 9 * * * /path/to/job1.sh && /path/to/job2.sh

Or run them in parallel:

0 9 * * * /path/to/job1.sh & /path/to/job2.sh

Best practice: Create a wrapper script that calls multiple jobs with proper error handling.

Advanced Topics

How do I handle timezone issues in cron?

Cron uses the server's system timezone by default. To handle timezones:

Method 1: Set CRON_TZ (modern cron)

CRON_TZ=America/New_York
0 9 * * * /path/to/job.sh

Method 2: Use TZ in the command

0 9 * * * TZ=America/New_York /path/to/job.sh

Method 3: Convert time manually

If your server is UTC and you want 9 AM EST (UTC-5):

0 14 * * * /path/to/job.sh  # 14:00 UTC = 9:00 AM EST

Note: CRON_TZ not supported in all implementations. Test first!

How do I prevent overlapping cron jobs?

If a job takes longer than its interval, you risk overlapping executions. Solutions:

Method 1: Use flock (file locking)

*/5 * * * * flock -n /tmp/myjob.lock /path/to/job.sh

Method 2: PID file check in script

#!/bin/bash
PIDFILE=/tmp/myjob.pid
if [ -f $PIDFILE ]; then
  kill -0 $(cat $PIDFILE) && exit
fi
echo $$ > $PIDFILE
# Your job code here
rm $PIDFILE

Method 3: Use a job queue system

  • Celery (Python)
  • Bull/BullMQ (Node.js)
  • Sidekiq (Ruby)

How do I log cron job output?

By default, cron sends output via email. To log to files:

Redirect stdout and stderr:

0 2 * * * /path/to/backup.sh >> /var/log/backup.log 2>&1

Separate logs:

0 2 * * * /path/to/job.sh >> /var/log/job.log 2>> /var/log/job-error.log

Add timestamps:

0 2 * * * echo "[$(date)] Starting job" >> /var/log/job.log && /path/to/job.sh >> /var/log/job.log 2>&1

Use logger for syslog:

0 2 * * * /path/to/job.sh 2>&1 | logger -t myjob

Why isn't my cron job running?

Common issues:

  1. Syntax error: Validate your expression with our generator
  2. Wrong PATH: Cron has limited PATH. Use absolute paths:
    0 2 * * * /usr/bin/python3 /home/user/script.py
  3. Permission denied: Ensure script is executable:
    chmod +x /path/to/script.sh
  4. Cron service not running:
    sudo systemctl status cron  # or crond
  5. User crontab not loaded:
    crontab -l  # verify your entries

Debug tips:

  • Run the command manually first
  • Check /var/log/syslog or /var/log/cron
  • Test with a simple command first: * * * * * echo "test" >> /tmp/crontest.log

Platform-Specific

How does cron work in Kubernetes?

Kubernetes uses CronJob resources with similar syntax:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: my-cronjob
spec:
  schedule: "0 */2 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: my-job
            image: my-image:latest
          restartPolicy: OnFailure

Key differences:

  • Uses standard 5-field cron syntax
  • Runs containers instead of scripts
  • Has additional fields like concurrencyPolicy
  • Timezone controlled by cluster/namespace settings

See Kubernetes CronJob examples β†’

How do I use cron expressions in AWS EventBridge?

AWS EventBridge uses 6-field cron expressions with an extra seconds field:

cron(minutes hours day-of-month month day-of-week year)

Examples:

  • Every day at 2 PM: cron(0 14 * * ? *)
  • Every 5 minutes: cron(0/5 * * * ? *)
  • Weekdays at 9 AM: cron(0 9 ? * MON-FRI *)

Special notes:

  • Use ? instead of * for day-of-month or day-of-week
  • Supports L (last), W (weekday), and # characters
  • All times in UTC

How do GitHub Actions cron schedules work?

GitHub Actions uses standard 5-field cron syntax in YAML:

on:
  schedule:
    - cron: '0 0 * * *'  # Daily at midnight UTC

Important notes:

  • UTC only: All times are in UTC timezone
  • Minimum interval: Every 5 minutes (not every minute)
  • Not guaranteed: May be delayed during high load
  • Needs activity: Disabled if repo inactive for 60 days

Example workflow:

name: Daily Build
on:
  schedule:
    - cron: '0 2 * * *'  # 2 AM UTC daily
  workflow_dispatch:  # Allow manual trigger
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: npm run build

How do I schedule jobs in Docker containers?

Option 1: Use host cron (simplest)

0 2 * * * docker exec my-container /app/backup.sh

Option 2: Install cron in container

# Dockerfile
RUN apt-get update && apt-get install -y cron
COPY crontab /etc/cron.d/my-cron
RUN chmod 0644 /etc/cron.d/my-cron
RUN crontab /etc/cron.d/my-cron
CMD ["cron", "-f"]

Option 3: Use external scheduler

  • Kubernetes CronJob
  • AWS ECS Scheduled Tasks
  • Docker Swarm with cron service

Best practice: Keep containers stateless, use external scheduler.

What about cron in serverless environments?

Serverless platforms have their own scheduling mechanisms:

AWS Lambda:

  • Use EventBridge (CloudWatch Events)
  • Cron or rate expressions
  • Example: rate(5 minutes) or cron(0 12 * * ? *)

Vercel Cron Jobs:

// vercel.json
{
  "crons": [{
    "path": "/api/cron",
    "schedule": "0 0 * * *"
  }]
}

Netlify Scheduled Functions:

// netlify.toml
[[functions]]
  name = "scheduled-function"
  schedule = "@daily"

Google Cloud Functions:

  • Use Cloud Scheduler
  • Standard cron syntax

Ready to Create Your Own Cron Expression?

Use our free visual generator to create perfect cron expressions in seconds.

Still Have Questions?

Check out our comprehensive resources: