How To Schedule a Cron Job to run Scripts in Debian 11.3
To Schedule a Cron Job to run Scripts in Debian 11.3
Introduction:
Scheduling a Job for a Specific Time The basic usage of cron is to execute a job in a specific time The cron daemon is a long-running process that executes commands at specific dates and times. You can use this to schedule activities, either as one-time events or as recurring tasks
Installation Steps:
Step1: Check the OS Version of Debian by using the below command
[root@linuxhelp ]# lsb_release -a
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
Step 2: Create a file “ test.sh” by using the below command
[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
45 01 18 Jun * /home/linuxhelp/Downloads/test.sh
Step 5: Change Directory by using the below command
[root@ linuxhelp]# cd /home/linuxhelp/
[root@ linuxhelp :home/linuxhelp/ ]# cd Downloads
Step 6: List the Directory at 01:45 AM by using the below command, The Scheduled job to create file and Directory will be created as shown in the below image
[root@ linuxhelp :home/linuxhelp/ cd Downloads]# ls -la
Step 7: To List the Scheduled jobs use the below command.
[root@linuxhelp]# crontab -l
45 01 18 Jun * /home/linuxhelp/Downloads/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 Debian 11.3. Your feedback is much welcome.
Comments ( 0 )
No comments available