Triggering regular tasks with Systemd

Alarm Clock

Article from Issue 214/2018
Author(s):

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

You might want to use your Linux system to automatically create a backup every evening and rotate the log files at regular intervals. In most distributions, time-controlled tasks are handled by the Cron daemon. But Systemd is an interesting alternative to Cron. Systemd controls the startup process of most distributions, and it can also trigger time-controlled and recurring tasks.

Service Providers

The first task is to tell Systemd which task to perform. To do this, you create a configuration file, the Service Unit. Listing 1 shows an example.

A service unit is a text file divided into several sections. The [Service] section is required. ExecStart= is followed by the command to be executed by the system. In Listing 1, Systemd would simply run a script that backs up the system to the /mnt directory. The [Unit] section adds some metadata. In the simplest case, Description= is followed by a description of the task.

[...]

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 Flatpak Updates

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

  • Systemd GUIs

    Graphical frontends make it easier to take full advantage of the Systemd process manager. We examine some leading tools for the KDE environment.

  • 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.

  • Systemd Graphical Tools

    Systemd has won the race, as indicated by the several tools that already offer a service just a mouse click away. We look at six of these tools.

comments powered by Disqus