April 16, 2026
Tutorials

How to Schedule Tasks Using Cron in AlmaLinux 10

How to Schedule Tasks Using Cron in AlmaLinux 10

Automating repetitive operations is among the most effective productivity skills you can build if you are in charge of a Linux server. Cron in AlmaLinux 10 provides you with a stable built-in solution to run nightly backups, scheduled reports, clean up log files, or restart services automatically, without having to use any third-party tools.

AlmaLinux 10 is a RHEL-compatible, enterprise-grade Linux distribution, which comes with cronie package, the default cron daemon found on Red Hat-based systems. This guide will show you how to schedule jobs with cron in AlmaLinux 10, what crontab syntax is, and how to operate cron jobs, as well as some best practices that cron users use in a production environment.

Table of Content

What Is Cron and Why Use It in AlmaLinux 10?

Cron is a time scheduling program to schedule jobs installed on Unix-like operating systems. It will read a configuration file named a crontab (cron table) and will execute commands or scripts at a given interval. Cron is controlled in AlmaLinux 10 by the crond daemon, which operates in the background and checks on the scheduled tasks every minute.

Cron, as a tool to perform tasks on Linux, is better than running the task manually since it removes the possibility of human error, is consistent, and even functions in the absence of a user. Cron is used by system administrators to automatically clean up disk space, dump databases, run security scans, renew certificates, and perform dozens of other tasks that are performed every day.

How to Schedule Tasks Using Cron in AlmaLinux 10

A cron job is a time-based task in Linux which is an automatic task that runs at set time intervals based on the crontab file. In version 10 of AlmaLinux, cron is run by the cronie daemon (crond), which parses crontab entries and runs the defined commands or scripts at the scheduled time, even when no user is logged in.

Every cron job has a five-field time expression (minute hour day month weekday) and then the command to execute it, e.g., 0 2 every day at 2:00 AM run: /scripts/ backup.sh. The crontab -e command is used to add or edit a cron job, and sudo systemctl status crond is used to check whether the daemon is running. This renders cron the most trustworthy in-built tool to automate repetitive administration activities of the system on the AlmaLinux 10 servers.

Step 1: Verify Cron Is Installed and Running on AlmaLinux 10

To ensure that the cron daemon is running in your AlmaLinux 10 system, first run the following command before scheduling any tasks in your terminal:

sudo systemctl status crond

sudo systemctl status crond

When the output is active (running), then your cron daemon is already running. In case it is not running, install it and start it with the following commands:

sudo dnf install cronie -y

sudo systemctl enable crond –now

The –now option not only allows crond to start at boot but also starts the service immediately in one command, the best practice on AlmaLinux 10.

Step 2: Understand the Crontab Syntax

Each cron job is described with the help of a particular syntax within the crontab file. A crontab line is of the following form:

* * * * * /path/to/command

│ │ │ │ │

│ │ │ │ └─── Day of the week (0–7, where 0 and 7 both represent Sunday)

│ │ │ └───── Month (1–12)

│ │ └─────── Day of the month (1–31)

│ └───────── Hour (0–23)

└─────────── Minute (0–59)

The crontab scheduling in Linux is based on understanding this five-field structure. The asterisk is used to indicate every, i.e., five asterisks in a line will execute every minute of every hour of every day.

Common Cron Schedule Examples

The following are the useful crontab examples that encompass the most frequent scheduling situations:

Schedule

Cron Expression

Description

Every minute

* * * * *

Runs every 60 seconds

Every hour

0 * * * *

Runs at the top of every hour

Every day at midnight

0 0 * * *

Daily at 12:00 AM

Every Sunday at 3 AM

0 3 * * 0

Weekly maintenance window

Every 15 minutes

*/15 * * * *

Four times per hour

First day of every month

0 0 1 * *

Monthly job

Cron special strings such as @reboot, @daily, @weekly, and @monthly also help to make your crontab entries easier when strict time scheduling is not important.

Step 3: Edit the Crontab File

The crontab -e command is used to add, edit, or remove your cron jobs. This will launch the crontab file in your default text editor – normally vi or nano on AlmaLinux 10:

crontab -e

crontab -e

To run the crontab of a particular user, the -u option is used with the user name being added at the end:

sudo crontab -u username -e

sudo crontab -u username -e

To list your existing cron jobs:

crontab -l

crontab -l

To delete all cron jobs of the user, execute:

crontab -r

crontab -r

Always take caution with crontab -r as it will delete all the jobs scheduled without any confirmation.

Step 4: Create Your First Cron Job in AlmaLinux 10

Now that you have a feel of the syntax and commands, the following is how to create an actual cron job. The next example will schedule a backup script to run each night at 2:00 AM:

0 2 * * * /home/user/scripts/backup.sh >> sudo /var/log/backup.log 2>&1

0 2 * * * /home/user/scripts/backup.sh >> sudo /var/log/backup.log 2>&1

Dividing this command:

  • 0 2 * * * — Run at 2:00 AM every day
  • home/user/scripts/backup.sh – The script to run.
  • /var/log/backup.log- Append standard output to a log file.
  • 2>1 – redirect error output to the same log file.

Using output to redirect to a log file is a recommended cron job management practice since it is much easier to troubleshoot a job that fails without generating any output.

Step 5: Use System-Wide Cron Directories

Besides user-level crontabs, AlmaLinux 10 also has system-wide cron directories where the scripts to run as root or with a specific time schedule must be placed. These directories are:

etc/cron.hourly/ — The scripts in this directory are run every hour.

etc/cron.daily/ — Scripts contained here run once daily.

etc/cron.weekly/ — Scripts in this directory are executed once a week.

etc/cron.monthly/ — Scripts that are put there are executed once monthly.

With these directories, all one has to do is copy the executable shell script to the corresponding folder. Ensure that the script is given execute permissions before being put there:

sudo chmod +x /etc/cron.daily/cleanup.sh

sudo chmod +x /etc/cron.daily/cleanup.sh

On RHEL-based systems such as AlmaLinux 10, these are controlled by /etc/cron.d/0hourly.

Step 6: Set Environment Variables in Crontab

Cron jobs execute in a bare-bones shell, so they do not inherit your normal user environment variables. This is a typical cause of work in the terminal, but fails in cron problems. You can set environment variables at the top of your crontab file:

SHELL=/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=admin@yourdomain.com

0 3 * * * /opt/scripts/database-backup.sh

set environment variables in crontab

Setting MAILTO will result in cron mailing output to the given address every time a job is executed, and this would be incredibly helpful when it comes to monitoring cron job output on production servers.

Troubleshooting Cron Jobs on AlmaLinux 10

When your cron job is not showing up as it should, the following are the most effective steps that you can use to troubleshoot your cron job:

Check the cron log to determine whether the job was run and whether it indicated any errors:

sudo grep CRON /var/log/cron

sudo grep CRON /var/log/cron

Manually test the script by manually running it in the terminal with the exact path specified in the crontab to eliminate path or permission problems.

Check permissions of the check file to make the script executable:

ls -l /path/to/your/script.sh

ls -l /path/to/your/script.sh

Absolute paths within your scripts are recommended since cron does not use the same PATH variable as your interactive shell does, so something like python3 or mysqldump might not be found, and you would need to fully specify its path, e.g., /usr/bin/python3.

Cron Job Management in AlmaLinux 10 Best Practices

These best practices will see your planned tasks reliably run on a production Linux environment:

  • Always specify both scripts and any commands that are called within those scripts with absolute paths, or they will fail to resolve the path.
  • Never dump output or errors to the default output, and always set them to log files so that you can debug with an audit trail.
  • Place a comment line before each cron job stating what it performs, with the character #, so that future administrators can know the purpose of each task, instead of having to guess.
  • Manually validate all scripts, then schedule using cron to ensure that they work correctly in isolation.
  • Monitoring of any cron jobs can be performed using cron monitoring tools or email alerts with MAILTO, so that jobs that fail or give undesired output can be notified.
  • Avoid scheduling a lot of resource-intensive jobs simultaneously to avoid server overload, particularly in shared infrastructure.

Conclusion

Task scheduling with cron in AlmaLinux 10 is very easy, provided you know the crontab syntax of 5 fields, how to manipulate the crontab file, and how to use environment variables appropriately. The cronie daemon included with AlmaLinux 10 offers a stable, production-ready implementation of automating Linux workflows, both simple and complex multi-step deployment pipelines.

With these methods discussed in this guide, such as creating your first cron job, taking advantage of system-wide cron directories, and best practices, you can safely and reliably automate routine system administration chores on any AlmaLinux 10 server.

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video