Schedule Future Tasks - RHCSA (RH134).pdf

support8872 462 views 10 slides Oct 10, 2024
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

Slides on how to schedule future tasks - Part of RHCSA (RH134) syllabus


Slide Content

Schedule future tasks

crontab
●Schedule tasks at set intervals.
●Automate repetitive tasks efficiently.
●Executes commands at predefined times.
●Syntax

Crontab options
●-e : Edit crontab file.
●-l : List crontab entries.
●-r : Remove crontab entries.
●-u : Specify user's crontab.

Edit a crontab file
●Command: crontab -e
Check date and time of the system
●Command: date

Add a cron job that runs at the modified minute
●Command: <minute> * * * * echo 'Hello World' > /path/to/output.txt

Wait for a specified amount of time, then check the contents of the output file
●Command: cat /path/to/output.txt

To list all the cron jobs
●Commands: crontab -l

at
●Schedule one-time tasks.
●Executes commands at specified time.
●Options
○-f: Execute commands from file.
○-l: List pending jobs.
○-r: Remove pending jobs.

Install the ‘at’ package and then start the services
●Command: dnf install at -y && systemctl start atd
Schedule a task to run after specified minute
●Command: at now + <number> minutes

After entering the ‘at’ prompt, schedule a task that will execute after the
specified time interval
●Command: echo 'Your custom message' > /path/to/output.txt
Note: Save the task by pressing ctrl+D and wait for 2 minutes and then check
the file using cat command.

crontab vs at