EDGE CLUSTERS: yt-dl.unixcorn.org (Media Suite) tor.unixcorn.org (Privacy Archive) cloud.unixcorn.org (Homelab Hub) paste.unixcorn.org (Encrypted Paste) unixcorn.org (DevOps Tools)
LINUX DEVOPS UTILITY

Crontab Schedule Visualizer & Translator

Construct complex crontab schedules, view natural language human descriptions, and preview the next calculated execution timestamps.

Presets:
0-59
0-23
1-31
1-12
0-6 (Sun-Sat)
HUMAN SCHEDULE DESCRIPTION
Every 15 minutes
crontab -e entry
*/15 * * * * /usr/local/bin/backup-job.sh >> /var/log/cron.log 2>&1

Next 6 Scheduled Runs:

Need a schedule to start from? Browse Linux crontab examples. If the script still fails, troubleshoot the cron job.

⏰ Production Crontab Engineering, Syntax Rules & Automation Guide

The cron daemon (crond) is the time-based job scheduler standard across Linux, Unix, and BSD servers. From automated database snapshots to SSL certificate renewals and log rotation, crontab automation is the backbone of reliable systems engineering.

1. Crontab Syntax Breakdown & Operator Rules

Operator Name Syntax Meaning Production Example
* Asterisk Matches every valid value in the field * * * * * (Runs every minute of every day)
, Comma Specifies a list of discrete values 0 9,13,18 * * * (Runs at 9:00 AM, 1:00 PM, and 6:00 PM)
- Hyphen Defines an inclusive range of numbers 0 9-17 * * 1-5 (Runs hourly between 9 AM and 5 PM on weekdays)
/ Slash Specifies interval increments / step values */15 * * * * (Runs every 15 minutes: 0, 15, 30, 45)

2. Special Crontab Macros Reference

Instead of manual 5-field numeric values, standard Vixie Cron and Systemd timers support human-readable shortcut macros:

Shortcut Macro Equivalent Cron Expression Exact Execution Frequency
@reboot N/A (Kernel trigger) Executes once upon system startup and daemon initialization.
@hourly 0 * * * * Runs at minute 0 of every hour.
@daily / @midnight 0 0 * * * Runs at 00:00 (midnight) every single night.
@weekly 0 0 * * 0 Runs at midnight every Sunday morning.
@monthly 0 0 1 * * Runs at midnight on the first calendar day of every month.
@yearly / @annually 0 0 1 1 * Runs at midnight on January 1st every year.

3. Enterprise Cron Best Practices & Environment Setup

# Top of your crontab (crontab -e):
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO="" # Disables local mail spam

# Database backup every night at 2:30 AM with atomic lock and log output:
30 2 * * * flock -n /var/lock/db_backup.lock /opt/scripts/backup.sh >> /var/log/backup.log 2>&1

❓ Linux Crontab Automation FAQ

Frequently asked questions about cron syntax, special strings, and production scheduling.

What are the 5 standard fields in a Linux crontab expression?

The five fields of a standard crontab line represent temporal increments from left to right: 1. Minute (0-59), 2. Hour (0-23 in 24-hour military time), 3. Day of the Month (1-31), 4. Month of the Year (1-12 or JAN-DEC), and 5. Day of the Week (0-6 where 0 and 7 both represent Sunday, or SUN-SAT). Followed by these five fields is the exact shell command or script path to execute.

Why do shell scripts run perfectly in interactive terminal but fail when executed by cron?

Cron jobs run in a severely restricted, non-interactive shell environment with a minimal PATH variable (typically only /usr/bin:/bin). Environment variables defined in your interactive ~/.bashrc or ~/.zshrc are not loaded. To resolve this: always use absolute paths for all commands and scripts (e.g. /usr/local/bin/python3 instead of python3), explicitly define PATH=/usr/local/bin:/usr/bin:/bin at the top of your crontab, or source your environment within the cron entry.

What does the special string '@reboot' do in crontab?

The @reboot macro instructs the cron daemon to execute the specified command once immediately after the system boots up and the crond service initializes, prior to any user logging in. It is widely used to launch lightweight background daemons, mount network shares, initialize temperature monitoring scripts, or post system startup webhooks into Slack or Discord.

Why is output redirection (>> /var/log/cron.log 2>&1) critical for cron jobs?

By default, if a cron job generates standard output (stdout) or error output (stderr) and no mail transfer agent (like Postfix or Sendmail) is configured, the local MTA attempts to write email messages to the local user's mailbox (/var/mail/root). Over time, thousands of uncollected error notifications will consume inode allocations and fill up storage. Redirecting both stdout and stderr with >> /path/to/log 2>&1 ensures all execution logs are preserved for debugging and prevents disk exhaustion.

How do I prevent a long-running cron job from overlapping with its next scheduled run?

Use the Linux utility flock (file lock) to enforce mutual exclusion. For instance: * * * * * flock -n /var/lock/backup.lock /usr/local/bin/backup.sh. The -n flag causes flock to fail silently and exit immediately if the previous run's lock file is still held, preventing process pile-ups and server memory exhaustion.