How To Install systemd-cron on Ubuntu 20.04

In this tutorial we learn how to install systemd-cron on Ubuntu 20.04. systemd-cron is systemd units to provide cron daemon & anacron functionality

Introduction

In this tutorial we learn how to install systemd-cron on Ubuntu 20.04.

What is systemd-cron

systemd-cron is:

Provides systemd units to run cron jobs in /etc/cron.hourly cron.daily cron.weekly and cron.monthly directories, without having cron or anacron installed. It also provides a generator that dynamicaly translate /etc/crontab, /etc/cron.d/* and user cronjobs in systemd units. Please notice this package provide a different set of features than Vixie-cron; trying to remain as simple as possible. By example, to avoid to run process through a wrapper, but have instead systemd run those dirrectly, it only send mails on error, including only a small blurb from the Journal; but doesn’t send the full output of processes.

There are three methods to install systemd-cron on Ubuntu 20.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install systemd-cron Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install systemd-cron using apt-get by running the following command:

sudo apt-get -y install systemd-cron

Install systemd-cron Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install systemd-cron using apt by running the following command:

sudo apt -y install systemd-cron

Install systemd-cron Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install systemd-cron using aptitude by running the following command:

sudo aptitude -y install systemd-cron

How To Uninstall systemd-cron on Ubuntu 20.04

To uninstall only the systemd-cron package we can use the following command:

sudo apt-get remove systemd-cron

Uninstall systemd-cron And Its Dependencies

To uninstall systemd-cron and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove systemd-cron

Remove systemd-cron Configurations and Data

To remove systemd-cron configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge systemd-cron

Remove systemd-cron configuration, data, and all of its dependencies

We can use the following command to remove systemd-cron configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge systemd-cron

References

Summary

In this tutorial we learn how to install systemd-cron package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.