Scheduled Tasks with cron
Part of one objective that names cron, at and timer units together. cron is the oldest and still the fastest to write. The detail that catches people is that a user crontab has five fields before the command and a system crontab has six - the extra one being the user to run as.
Deploy and Maintain Guide 43 of 67 Beginner
- OSRHEL 10.0
- Kernel6.12.0-55.9.1.el10_0
- dnf4.20.0
- Flatpak1.16.0
- TimeAbout 13 min
The package is cronie and the service is crond. crontab -e edits your own; crontab -e -u <user> edits somebody else's and needs root. Never edit /var/spool/cron/<user> directly - crontab validates the syntax and reloads, and a hand-edited file can be silently ignored.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RHCSA-A01 | 192.168.0.31 | RHEL 10.0 | Practice node (graded) - spare /dev/sda | 2 Core | 4 GB | 50 GB + 15 GB |
This guide includes
Use this for the first of three tools that one objective names. This matters because a user crontab and a system crontab are not the same format - the system one has a sixth field deciding who runs it.
- reading the format
- writing a user crontab
- writing a system crontab, and meeting the sixth field
- using the shorthand schedules, and checking the job actually ran
Before you start
- A sudo-capable account.
- The session writes a user crontab and a file in
/etc/cron.d, and removes both.
-
The format
-
A user crontab
-
System crontabs, and the sixth field
-
Shorthand, and checking it ran