Skip to content
Home

Cron: the Unix-like time-based job scheduler

Cron is a time-based job scheduler for Unix-like systems. It runs commands or scripts at specified times or intervals using per-user crontabs and supports special schedules and alternatives like anacron or systemd timers.

Cron is a background daemon and set of utilities used to schedule commands or scripts to run automatically at defined times or intervals on Unix-like operating systems. It is widely used on systems derived from or compatible with UNIX and on distributions of Linux. Administrators and users rely on cron to automate routine maintenance, recurring jobs and other repetitive tasks without manual intervention.

Image gallery

1 Image

Core concepts and components

The basic unit of configuration is the crontab (cron table), a simple text file that lists scheduled jobs. Each line in a crontab usually contains five time-and-date fields followed by the command to execute. The fields represent minute, hour, day of month, month, and day of week. A typical entry looks like: 0 2 * * * /path/to/backup, which runs a backup at 02:00 every day. Crontabs can contain comments beginning with # and may set environment variables that apply to all jobs.

  • Daemon: the cron process runs continuously and checks schedules.
  • Crontab files: per-user crontabs and system-wide files are used to store schedules.
  • Special time strings: many implementations support shortcuts such as @reboot, @daily, @hourly.

Syntax details and examples

Time fields accept single values, ranges (e.g., 1-5), lists (e.g., 1,15,30), and step values (e.g., */10 for every ten minutes). Examples of common tasks: run a script every 15 minutes, clear temporary files at midnight, or fetch updates on the hour. Cron lines are evaluated by the daemon and executed by a shell; standard output and errors are typically mailed to the owning user or can be redirected to files.

History, name and alternatives

The word "cron" derives from the Greek χρόνος (chronos), meaning time, which reflects its role as a scheduler. Over decades cron implementations have evolved; notable variations and related utilities include Vixie cron, cronie, and fcron. Because cron assumes the system is running continuously, systems that are not always on may use anacron or similar tools to guarantee missed jobs run when the machine resumes. More recently, some systems use systemd timers as an alternative scheduler integrated with the init system.

Common uses and practical notes

Administrators employ cron for tasks such as automated backups, rotating logs, updating databases, running monitoring checks, and fetching or sending data at scheduled intervals (for example, downloading files from the Internet or retrieving email at set times). Because cron jobs inherit a limited environment, scripts often need to set PATH or use full paths for commands. Permission and ownership are important: each user can have a crontab, and system-wide crontabs typically reside in standard locations managed by the operating system.

Distinctions and notable facts

Cron is designed for recurring scheduling rather than event-driven tasks. It excels at predictable, time-based automation but is not a substitute for supervisory process managers. To prevent overlapping runs, administrators may use locking mechanisms or wrapper scripts. When auditing or troubleshooting scheduled tasks, common places to check include the user's crontab, system crontab files, and the cron daemon logs. The simplicity and ubiquity of cron have kept it a fundamental tool in system administration for many years.

For more information about specific implementations, configuration examples, and best practices, consult system documentation or distribution guides and resources such as chronos-related references.

Questions and answers

Q: What is Cron?

A: Cron is a computer program used to schedule tasks at specific time intervals.

Q: Where is Cron used?

A: Cron is used in UNIX computer operating systems and operating systems that are similar to UNIX, like Linux.

Q: What kind of tasks can be scheduled with Cron?

A: Most repetitive tasks can be scheduled with Cron. It is often used to automate tasks related to a computer or computer network's maintenance or administration, although it can be used for many other tasks like downloading files from the Internet and downloading email at specific times or dates.

Q: What does the name Cron come from?

A: The name of the Cron computer program is from the word cron, which is from the Greek word for time, χρόνος (chronos).

Q: How is Cron set up?

A: Cron is set up by editing a file called a crontab (cron table). This file lists the specific tasks for the computer to run and when the tasks should be run.

Q: What is a crontab?

A: A crontab is a file that lists the specific tasks for the computer to run and when the tasks should be run.

Q: What kind of repetitive tasks can Cron be used for?

A: Most repetitive tasks related to a computer or computer network's maintenance or administration can be automated with Cron. It can also be used for many other tasks like downloading files from the Internet and downloading email at specific times or dates.

Related articles

Author

AlegsaOnline.com Cron: the Unix-like time-based job scheduler

URL: https://en.alegsaonline.com/art/24288

Share

Sources