ToolStack
KO

Crontab / Cron Reference

Crontab commands, schedule expressions, and common scheduling examples

Your data never leaves the browser — all processing is done locally 0 server requests

01

Basic crontab Commands

  • crontab -e

    Edit your crontab (changes take effect immediately on save)

  • crontab -l

    List your current crontab entries

  • crontab -r

    Remove all your crontab entries ※ deletes without confirmation, use with caution

  • sudo crontab -u 사용자 -l

    View another user's crontab entries

  • sudo systemctl status cron

    Check the cron daemon status (use crond on RHEL-based systems)

  • cat /etc/crontab

    View the system-wide crontab (6-field format including user column)

02

Schedule Expressions — 5-Field Syntax

Fields left to right: minute(0-59) hour(0-23) day(1-31) month(1-12) weekday(0-7, both 0 and 7 = Sunday). * means any value, */n means every n, a-b is a range, a,b is a list.

  • * * * * * 명령

    Run every minute

  • */5 * * * * 명령

    Run every 5 minutes

  • 0 * * * * 명령

    Run at the top of every hour

  • 30 2 * * * 명령

    Run every day at 02:30 AM

  • 0 9 * * 1-5 명령

    Run at 9:00 AM on weekdays (Mon–Fri)

  • 0 0 * * 0 명령

    Run at midnight every Sunday

  • 0 0 1 * * 명령

    Run at midnight on the 1st of every month

  • 0 0,12 * * * 명령

    Run at midnight and noon every day

  • 0 4 1 1 * 명령

    Run at 04:00 on January 1st every year

03

Special Strings (Shortcuts)

  • @reboot 명령

    Run once at system startup

  • @hourly 명령

    Run at the top of every hour (same as 0 * * * *)

  • @daily 명령

    Run at midnight every day (same as @midnight)

  • @weekly 명령

    Run at midnight every Sunday

  • @monthly 명령

    Run at midnight on the 1st of every month

  • @yearly 명령

    Run at midnight on January 1st every year (same as @annually)

04

Tips — Environment, Logging & Overlap Prevention

Cron runs in a minimal environment different from your login shell. Always use absolute paths for commands and files to be safe.

  • SHELL=/bin/bash

    Set the shell to use at the top of the crontab

  • PATH=/usr/local/bin:/usr/bin:/bin

    Define PATH at the top of the crontab (prevents "command not found" errors)

  • MAILTO=""

    Disable email notifications for job output

  • 0 3 * * * /home/user/backup.sh >> /var/log/backup.log 2>&1

    Redirect both stdout and stderr to a log file

  • */10 * * * * flock -n /tmp/job.lock /path/job.sh

    Skip if the previous run is still going, preventing overlapping jobs

05

Verification & Debugging

  • grep CRON /var/log/syslog

    Check cron execution history (Debian/Ubuntu)

  • sudo tail -f /var/log/cron

    Follow cron logs in real time (RHEL/CentOS)

  • journalctl -u cron --since today

    View today's cron logs in a systemd environment

  • date

    Check the server's current time and timezone (timezone mismatch can cause unexpected run times)

  • ls /etc/cron.daily/

    List system scripts that run automatically every day

Crontab: Scheduling Tasks on Linux

Cron is the standard task scheduler on Unix-like systems. Each line in a crontab file defines a job with a 5-field time expression followed by the command to run: minute (0–59), hour (0–23), day of month (1–31), month (1–12), day of week (0–7, where 0 and 7 are Sunday).

Common patterns: */5 * * * * (every 5 minutes), 0 2 * * * (daily at 2 AM), 0 9 * * 1-5 (weekdays at 9 AM). Use crontab -l to list jobs and crontab -r to remove all jobs (be careful with -r).

⚠ crontab -r removes ALL cron jobs without confirmation. Always run crontab -l first to review your jobs before deleting them.

FAQ

How do I edit my crontab?
Run crontab -e to open the cron table in your default editor. Add one job per line using the 5-field format: minute hour day month weekday command. Save and exit to activate.
What does */5 mean in a cron expression?
"Every 5 units." For example, */5 in the minutes field means "every 5 minutes." The * means "all valid values" and /5 means "every 5th one."
My cron job is not running — how do I debug it?
Common causes: wrong path (cron uses a minimal environment, so use absolute paths), missing execute permission on the script, or silent errors. Redirect output: * * * * * /path/to/script.sh >> /tmp/cron.log 2>&1 to capture both stdout and stderr.

Related Tools