Comparing cron and systemd for task automation

Timer Time

Article from Issue 301/2025
Author(s): , Author(s): , Author(s):

Cron and systemd are two options for automating tasks in Linux. Which is best? That all depends…

Automation is a cornerstone of modern Linux system administration, bringing efficiency in executing repetitive tasks. In the past, the venerable and reliable cron utility was the go-to tool for automating recurring tasks. In recent years, however, a more modern alternative has emerged as a competitor to the classic cron: systemd timers. Although the systemd init system [1] has been around since 2010, setting timers through systemd still seems exotic and new to many Linux users. A large contingent of the Linux crowd never really had a problem with cron and has never seen any reason to switch. Still, systemd offers advanced features that aren't available with cron, and once you get past the learning curve, systemd timers aren't as complicated as they look. We decided it was time to compare these two powerful automation techniques side by side. We'll start with brief descriptions, then compare some of the pertinent features, and we'll end with a look at a few practical examples. If you're in need of some additional background, see the cron tutorial later in this issue.

Cron for Task Automation

Cron, derived from the Greek word "chronos" meaning time, is a time-based job scheduler in Unix-like operating systems [2]. Cron allows users to schedule commands or scripts, known as cron jobs, to run periodically at fixed times, dates, or intervals. The behavior of cron is governed by crontab (cron table) files. A crontab file is a configuration file specifying the schedule and the command you wish to execute [3]. Users can create their own crontab files, and there is typically a system-wide crontab file for administrative tasks.

The fundamental unit of cron is the cron job, which is defined by a specific syntax within the crontab file. Each line in a crontab represents a job and consists of a cron expression followed by the command to execute. The standard cron expression comprises five fields representing the minute (0-59), hour (0-23), day of the month (1-31), month (1-12 or JAN-DEC), and day of the week (0-6 or SUN-SAT). These fields are separated by spaces, and each can contain specific values, ranges, lists, or the asterisk (*) to denote all possible values within that field. For instance,  * * * * /path/to/command would execute the specified command every minute.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Systemd Timers

    Systemd can start timers that automatically perform tasks at specified times. The configuration files are known as timer units.

  • Systemd Flatpak Updates

    You can automate Flatpak updates without a package manager using systemd's services and timers.

  • Tutorials – Systemd

    Take control of the services running on your Linux machine

  • Systemd Units

    Systemd units use files to control resources that Systemd manages.

  • Command Line: Systemd

    Wondering what all the fuss is about systemd? We explain the basic concepts and capabilities of the new system management suite – coming soon to a distro near you.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News