• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to schedule a Cron Job to run scripts on Rocky Linux 8.6

  • 00:24 cat /etc/os-release
  • 00:37 systemctl status crond
  • 00:56 vim /mnt/sample.sh
  • 01:46 cat /etc/crontab
  • 02:04 crontab -e
  • 02:58 crontab -l
  • 03:40 rm -rvf test/ file.txt
7169

To Schedule A Cron Job To Run Scripts On Rocky Linux 8.6

Introduction

The crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list.

Installation Steps:

Step 1: Check the installed version of OS by using the below command

[root@linuxhelp ~]# cat /etc/os-release 
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"

Step 2: Check the crond 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 Wed 2022-07-06 02:07:23 EDT; 11min ago
 Main PID: 22791 (crond)
    Tasks: 1 (limit: 17274)
   Memory: 1.1M
   CGroup: /system.slice/crond.service
           └─22791 /usr/sbin/crond -n

Step 3: Now create the .sh file by the name of sample.sh

[root@linuxhelp ~]# vim /mnt/sample.sh

mkdir /test
touch /file.txt

Step 4: Check the crontab format by using the below command

[root@linuxhelp /]# cat /etc/crontab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

#For details see man 4 crontabs
#Example of job definition:
#.---------------- minute (0 - 59)
#|  .------------- hour (0 - 23)
#|  |  .---------- day of month (1 - 31)
#|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
#|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
#|  |  |  |  |
#*  *  *  *  * user-name  command to be executed

Step 5: Create the entry in crontab by using the below command

[root@linuxhelp ~]# crontab -e
*	*               *       *       * sh /mnt/sample.sh

Step 6: Now list the crontab entry by using the below command

[root@linuxhelp ~]# crontab -l
* 	* 		*	*	* sh /mnt/sample.sh

Step 7: Now list the location / (before executing the command time 2.38) by using the below command

[root@linuxhelp ~]# cd /
[root@linuxhelp /]# ls -la
total 28
dr-xr-xr-x.  18 root root  252 Jul  6 02:25 .
dr-xr-xr-x.  18 root root  252 Jul  6 02:25 ..
lrwxrwxrwx.   1 root root    7 Oct 10  2021 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Jul  6 02:07 boot
drwxr-xr-x.  20 root root 3200 Jul  6 01:41 dev
drwxr-xr-x. 150 root root 8192 Jul  6 02:07 etc

-rw-r--r--.   1 root root    0 Jul  6 02:38 file.txt
drwxr-xr-x.   3 root root   23 Jun 27 08:48 home
lrwxrwxrwx.   1 root root    7 Oct 10  2021 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 Oct 10  2021 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 Oct 10  2021 media
drwxr-xr-x.   3 root root   35 Jul  6 02:24 mnt
drwxr-xr-x.   2 root root    6 Oct 10  2021 opt
dr-xr-xr-x. 243 root root    0 Jul  6 01:41 proc
dr-xr-x---.  17 root root 4096 Jul  6 02:24 root
drwxr-xr-x.  47 root root 1340 Jul  6 02:07 run
lrwxrwxrwx.   1 root root    8 Oct 10  2021 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 Oct 10  2021 srv
dr-xr-xr-x.  13 root root    0 Jul  6 01:41 sys
drwxr-xr-x.   2 root root    6 Jul  6 02:25 test
drwxrwxrwt.  26 root root 4096 Jul  6 02:37 tmp
drwxr-xr-x.  13 root root  158 Jun 27 08:44 usr
drwxr-xr-x.  22 root root 4096 Jul  5 03:23 var

Step 8: Now list the location / (after executing the command time 2.39) by using the below command

[root@linuxhelp /]# ls -la
total 28
dr-xr-xr-x.  18 root root  252 Jul  6 02:39 .
dr-xr-xr-x.  18 root root  252 Jul  6 02:39 ..
lrwxrwxrwx.   1 root root    7 Oct 10  2021 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Jul  6 02:07 boot
drwxr-xr-x.  20 root root 3200 Jul  6 01:41 dev
drwxr-xr-x. 150 root root 8192 Jul  6 02:07 etc
-rw-r--r--.   1 root root    0 Jul  6 02:39 file.txt
drwxr-xr-x.   3 root root   23 Jun 27 08:48 home
lrwxrwxrwx.   1 root root    7 Oct 10  2021 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 Oct 10  2021 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 Oct 10  2021 media
drwxr-xr-x.   3 root root   35 Jul  6 02:24 mnt
drwxr-xr-x.   2 root root    6 Oct 10  2021 opt
dr-xr-xr-x. 243 root root    0 Jul  6 01:41 proc
dr-xr-x---.  17 root root 4096 Jul  6 02:24 root
drwxr-xr-x.  47 root root 1340 Jul  6 02:07 run
lrwxrwxrwx.   1 root root    8 Oct 10  2021 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 Oct 10  2021 srv
dr-xr-xr-x.  13 root root    0 Jul  6 01:41 sys
drwxr-xr-x.   2 root root    6 Jul  6 02:39 test
drwxrwxrwt.  26 root root 4096 Jul  6 02:38 tmp
drwxr-xr-x.  13 root root  158 Jun 27 08:44 usr
drwxr-xr-x.  22 root root 4096 Jul  5 03:23 var

Step 9: Now remove the directory and file by using the below command

[root@linuxhelp /]# rm -rvf test/ file.txt 
removed directory 'test/'
removed 'file.txt'

Step 10: Now list the location (time 3.07) by using the below command

[root@linuxhelp /]# ls -la
total 28
dr-xr-xr-x.  17 root root  224 Jul  6 03:07 .
dr-xr-xr-x.  17 root root  224 Jul  6 03:07 ..
lrwxrwxrwx.   1 root root    7 Oct 10  2021 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Jul  6 02:07 boot
drwxr-xr-x.  20 root root 3200 Jul  6 01:41 dev
drwxr-xr-x. 150 root root 8192 Jul  6 02:07 etc
drwxr-xr-x.   3 root root   23 Jun 27 08:48 home
lrwxrwxrwx.   1 root root    7 Oct 10  2021 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 Oct 10  2021 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 Oct 10  2021 media
drwxr-xr-x.   3 root root   35 Jul  6 02:24 mnt
drwxr-xr-x.   2 root root    6 Oct 10  2021 opt
dr-xr-xr-x. 244 root root    0 Jul  6 01:41 proc
dr-xr-x---.  17 root root 4096 Jul  6 02:24 root
drwxr-xr-x.  47 root root 1340 Jul  6 02:07 run
lrwxrwxrwx.   1 root root    8 Oct 10  2021 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 Oct 10  2021 srv
dr-xr-xr-x.  13 root root    0 Jul  6 01:41 sys
drwxrwxrwt.  27 root root 4096 Jul  6 03:07 tmp
drwxr-xr-x.  13 root root  158 Jun 27 08:44 usr
drwxr-xr-x.  22 root root 4096 Jul  5 03:23 var

Step 11: List the location after 1 minute 03.08 by using the below command

[root@linuxhelp /]# ls -la
total 28
dr-xr-xr-x.  18 root root  252 Jul  6 03:08 .
dr-xr-xr-x.  18 root root  252 Jul  6 03:08 ..
lrwxrwxrwx.   1 root root    7 Oct 10  2021 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 Jul  6 02:07 boot
drwxr-xr-x.  20 root root 3200 Jul  6 01:41 dev
drwxr-xr-x. 150 root root 8192 Jul  6 02:07 etc
-rw-r--r--.   1 root root    0 Jul  6 03:08 file.txt
drwxr-xr-x.   3 root root   23 Jun 27 08:48 home
lrwxrwxrwx.   1 root root    7 Oct 10  2021 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 Oct 10  2021 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 Oct 10  2021 media
drwxr-xr-x.   3 root root   35 Jul  6 02:24 mnt
drwxr-xr-x.   2 root root    6 Oct 10  2021 opt
dr-xr-xr-x. 244 root root    0 Jul  6 01:41 proc
dr-xr-x---.  17 root root 4096 Jul  6 02:24 root
drwxr-xr-x.  47 root root 1340 Jul  6 02:07 run
lrwxrwxrwx.   1 root root    8 Oct 10  2021 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 Oct 10  2021 srv
dr-xr-xr-x.  13 root root    0 Jul  6 01:41 sys
drwxr-xr-x.   2 root root    6 Jul  6 03:08 test
drwxrwxrwt.  26 root root 4096 Jul  6 03:07 tmp
drwxr-xr-x.  13 root root  158 Jun 27 08:44 usr
drwxr-xr-x.  22 root root 4096 Jul  5 03:23 var

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to schedule a Cron Job to run scripts on Rocky Linux 8.6. Your feedback is much welcome.

Tags:
muhammad
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How to execute a Linux cron job every second using Crontab?

A

You cannot schedule an every-second cronjob. In cron, the minimum unit you can specify is a minute. In a typical scenario, there is no reason for most of us to run any job every second in the system.

Q

What is the name of the service associated with cron jobs?

A

The name of the service associated with cron jobs is crond

Q

What will happen if we delete /etc/cron.deny and /cron.allow files?

A

Only root users will be able to schedule cron jobs.

Q

Where do the logs related to cron jobs collected?

A

In the file /var/log/cron.

Q

Is it necessary to restart crond service after editing crontab for any user?

A

No, it is not necessary to restart crond service after editing crontab for any user.

Related Tutorials in How to schedule a Cron Job to run scripts on Rocky Linux 8.6

Related Tutorials in How to schedule a Cron Job to run scripts on Rocky Linux 8.6

How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to Install and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to use Aureport command on Linux
How to use Aureport command on Linux
Nov 28, 2017
How to install Development tools on Linux
How to install Development tools on Linux
Jun 12, 2018
How to Install mod_ssl and SSL certificate on Oracle Linux
How to Install mod_ssl and SSL certificate on Oracle Linux
Dec 30, 2021
How to install Nextcloud on Ubuntu 22.04 version
How to install Nextcloud on Ubuntu 22.04 version
Jun 23, 2023
how to schedule a cron job to run a script on Ubuntu 16.04
how to schedule a cron job to run a script on Ubuntu 16.04
Jun 8, 2018

Related Forums in How to schedule a Cron Job to run scripts on Rocky Linux 8.6

Related Forums in How to schedule a Cron Job to run scripts on Rocky Linux 8.6

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018

Related News in How to schedule a Cron Job to run scripts on Rocky Linux 8.6

Related News in How to schedule a Cron Job to run scripts on Rocky Linux 8.6

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.