How to schedule Cron Job on Fedora 34
To Schedule A Job Using Crontab
Introduction
Cron is a system that helps Linux users to schedule any task. However, a cron job is any defined task to run in a given time period. It can be a shell script or a simple bash command. Cron job helps, us automate our routine tasks, it can be hourly, daily, monthly, etc. The cron daemon is a long-running process that executes commands at specific dates and times.
Installation Procedure
Step 1: Check the installed OS version by using the below command
[liveuser@linuxhelp ~]$ cat /etc/os-release
NAME=Fedora
VERSION="34 (Workstation Edition)"
ID=fedora
VERSION_ID=34
VERSION_CODENAME=""
PLATFORM_ID="platform:f34"
Step 2: Log in as a Root user by using the below command
[liveuser@linuxhelp ~]$ su -
Last login: Mon Oct 25 14:01:02 EDT 2021 on pts/0
Step 3: Install Crontab by using the below command
[root@linuxhelp ~]# dnf install crontabs
Fedora Modular 34 - x86_64 - Updates 8.9 kB/s | 6.7 kB 00:00
Fedora Modular 34 - x86_64 - Updates 85 kB/s | 229 kB 00:02
Fedora 34 - x86_64 - Updates 5.2 kB/s | 4.5 kB 00:00
Fedora 34 - x86_64 - Updates 909 kB/s | 3.0 MB 00:03
Fedora 34 - x86_64 731 kB/s | 74 MB 01:43
Last metadata expiration check: 0:00:01 ago on Tue 26 Oct 2021 12:18:26 PM EDT.
Dependencies resolved.
========================================================================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================================================================
Installing:
crontabs noarch 1.11-24.20190603git.fc34 fedora 18 k
Installing dependencies:
cronie-anacron x86_64 1.5.7-1.fc34 fedora 32 k
Installing weak dependencies:
cronie x86_64 1.5.7-1.fc34 fedora 116 k
Step 4: Start, Enable crontab Service by using the below command
[root@linuxhelp ~]# systemctl start crond
[root@linuxhelp ~]# systemctl enable crond
Step 5: Check the crontab status by using the below command
[root@linuxhelp ~]# systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-10-26 12:19:30 EDT; 45s ago
Main PID: 65172 (crond)
Tasks: 1 (limit: 2261)
Memory: 1.1M
CPU: 17ms
CGroup: /system.slice/crond.service
└─65172 /usr/sbin/crond –n
Step 6: Edit crontab file by using the below command
[root@linuxhelp ~]# crontab –e
NU nano 5.6.1 /tmp/crontab.t8LcVZ
26 12 * * * mkdir jpj.text
26 12 * * * touch test.file
Step 7: Check created cron file by using the below command
[root@linuxhelp ~]# crontab -l
26 12 * * * mkdir jpj.text
26 12 * * * touch test.fil
Step 8: Then restart the crontab service
root@linuxhelp ~]# systemctl restart crond
step 9: To using this command to check cron job
[root@linuxhelp ~]# ll
total 16
-rw-------. 1 root root 12139 Apr 23 2021 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4096 Oct 26 12:26 jpj.text
-rw-r--r--. 1 root root 0 Oct 26 12:26 test.file
Step 10: Check the cron job working status as shown in the below images
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to schedule a job using crontab. Your feedback is much welcome.