AMP AMP

How to Schedule a Cron Job to run Scripts in Oracle Linux 8.5

To Schedule a Cron Job to run Scripts in Oracle Linux 8.5

Introduction:

The cron daemon is a long-running process that executes scheduled commands at specific dates and times, either as one-time events or as recurring tasks.

Installation Steps:

Step 1: Check the Version of Oracle Linux by using the below command

[root@linuxhelp linuxhelp]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="8.5"
ID="ol"

Step 2: Create a file “ test.sh” script at 3:58 PM Add the following lines, Save and quit the file.

[root@linuxhelp linuxhelp]# vim test.sh
touch /home/linuxhelp/Downloads/file1.txt
mkdir /home/linuxhelp/Downloads/folder

Step 3: Grant Permission by using the below command

[root@linuxhelp linuxhelp]# chmod u+x test.sh

Step 4: Assign a Cron job and run the below command.

[root@linuxhelp]# crontab -e
00 04 11 Jun * /home/linuxhelp/test.sh

Step 5: Change Directory by using the below command

[root@linuxhelp linuxhelp]# cd Downloads

Step 6: List the Directory at 04:00PM , The Scheduled job to create file and Directory will be created as shown in the below image.

Step 7: To List the Scheduled jobs use the below command.

[root@linuxhelp]# crontab -l
00 04 11 Jun * /home/linuxhelp/test.sh

Step 8: To Remove the Scheduled jobs use the below command.

[root@linuxhelp]# crontab -r

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 in Oracle Linux 8.5. Your feedback is much welcome.

FAQ
Q
How many cron jobs are too many?
A
The cron daemon has a limit on how many jobs it will run simultaneously. By default, it is 100 jobs
Q
How to Create or Edit a crontab File
A
Create a new crontab file, or edit an existing file using the command $ crontab -e [ username ].
Q
Where are crontab logs stored?
A
Crontab logs stored for /var/log/cron
Q
Can cron run multiple commands at the same time?
A
We can run several commands in the same cron job by separating them with a semi-colon ( ; )
Q
What is the use of * * * * * In cron?
A
It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week