« Back to Systemd: Frequently Asked Questions

How to schedule a periodic task with systemd

How to schedule a periodic task with systemd?

To create a repeating task, create a timer unit and link that to an existing service unit.

Systemd uses different types of units. One of them is the timer unit, which can be used to schedule a periodic task. This timer unit is linked to an existing service unit and will activate the service according to the defined schedule. The timer unit can be defined using the information about systemd timers.

Timers use one or more OnCalendar definitions to specify when execution of the timer should happen. As systemd timers are very versatile and provide good monitoring options, they are a good replacement of cronjobs. The only downside is that slightly more configuration is needed when a just a single shell script needs to be executed, as you need to create both the timer as service unit.

Other questions related to Systemd

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon