RHEL9 Complete job scheduling by using crontab and at command

Опубликовано: 21 Октябрь 2024
на канале: techessay
29
2

Agenda of this video-
Understand Job Scheduling in Linux
crontab and at
Need of Job Scheduling-
1. We have to take daily Backup of server
2. We have to monitor our server (ram,process,disk etc)
3. We want to excute some commande at specific time
etc
What is crontab & how to administrate the crontab
What Crontab do- Automate/Schedule your Linux system tasks.
The cron daemon (crond) is a system-managed executable that runs in memory with which users may schedule tasks. The user command to work with the cron service is crontab (cron table). The crontab file is a simple text file that instructs the cron daemon to perform a task at a certain time or interval. Any user may schedule cron tasks or jobs on a system. The task runs under the user account from which it was created. In other words, if you create a cron task, it runs with your user account's permissions. The same is true for any user on the system, including the root user.

Using cron
You can issue the man crontab command to see all possible options, but there are generally two that work for most users: -l (list) and -e (edit) -r removing all crontab jobs.

To see a list of your configured cron tasks, use:

$ crontab -l
no crontab for khess
If you have no cron tasks running yet. To create one, you need to edit your crontab file:

$ crontab -e
Note: There is no file name or designation of any kind required when creating a crontab entry. Each user has only one crontab file and you add all tasks to it.
$crontab -r -i
Crontab has predefined syntax to write the time table and commands-
1. Time table (It define the time table on which command/script will excute)
2. Commands / Script



Time table Command /Script
Day of Week 0-6 Where 0 denoted Sunday then 1-Monady
Day of week 1-7 where 7 denote Sunday
Crontab has Two Important files-
cron.allow- Then Only Allowd user can edit their crontab file and remaining user are not able to edit their crontab.
cron.deny- Then only That user are denied and not able to edit their crontab file and remaining user are able to edit their file.

at command -
#at 09.10
#atq
if you have to exit from at prompt ctrl+d