English Sinhala
Automating System Tasks
indexterm:[Automated Tasks] Tasks, also known as _jobs_, can be configured to run automatically within a specified period of time, on a specified date, or when the system load average decreases below 0.8.
{MAJOROS} is pre-configured to run important system tasks to keep the system updated. For example, the slocate database used by the [command]#locate# command is updated daily. A system administrator can use automated tasks to perform periodic backups, monitor the system, run custom scripts, and so on.
{MAJOROS} comes with the following automated task utilities: [command]#cron#, [command]#anacron#, [command]#at#, and [command]#batch#.
Every utility is intended for scheduling a different job type: while Cron and Anacron schedule recurring jobs, At and Batch schedule one-time jobs (refer to xref:Automating_System_Tasks.adoc#s1-autotasks-cron-anacron[Cron and Anacron] and xref:Automating_System_Tasks.adoc#s1-autotasks-at-batch[At and Batch] respectively).
{MAJOROS} supports the use of `systemd.timer` for executing a job at a specific time. See man `systemd.timer(5)` for more information.
Cron and Anacron
indexterm:[anacron]indexterm:[cron] Both Cron and Anacron can schedule execution of recurring tasks to a certain point in time defined by the exact time, day of the month, month, day of the week, and week.
Cron jobs can run as often as every minute. However, the utility assumes that the system is running continuously and if the system is not on at the time when a job is scheduled, the job is not executed.
On the other hand, Anacron remembers the scheduled jobs if the system is not running at the time when the job is scheduled. The job is then executed as soon as the system is up. However, Anacron can only run a job once a day. Also note that by default, Anacron only runs when your system is running on AC power and will not run if your system is being powered by a battery; this behavior is set up in the [filename]`/etc/cron.hourly/0anacron` script.
Installing Cron and Anacron
To install Cron and Anacron, you need to install the [package]*cronie* package with Cron and the [package]*cronie-anacron* package with Anacron ([package]*cronie-anacron* is a sub-package of [package]*cronie*).
To determine if the packages are already installed on your system, issue the following command:
[command]#rpm -q cronie cronie-anacron#
The command returns full names of the [package]*cronie* and [package]*cronie-anacron* packages if already installed, or notifies you that the packages are not available.
To install these packages, use the [command]#dnf# command in the following form as `root`:
[command]#dnf install _package_pass:attributes[{blank}]#
For example, to install both Cron and Anacron, type the following at a shell prompt:
~]#{nbsp}dnf install cronie cronie-anacron
For more information on how to install new packages in {MAJOROS}, see xref:package-management/DNF.adoc#sec-Installing[Installing Packages].