0% found this document useful (0 votes)
53 views4 pages

LAB 12 - Scheduling Tasks

Uploaded by

Thien Duong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views4 pages

LAB 12 - Scheduling Tasks

Uploaded by

Thien Duong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Exercise 12.

1 Running Scheduled Tasks Through cron


In this exercise, you apply some of the cron basics. You schedule
cron jobs using different mechanisms.
1. Open a root shell. Type cat /etc/crontab to get an impression
of the contents of the /etc/crontab configuration file.

2. Type crontab -e . This opens an editor interface that by default


uses vi as its editor. Add the following line:

3. Use the vi command :wq! to close the editing session and write
changes.

4. Use cd /etc/cron.hourly . In this directory, create a script file


with the name eachhour that contains the following line:
logger This message is written at $(date)
5. Use chmod +x eachhour to make the script executable; if you
fail to make it executable, it will not work.
6. Now enter the directory /etc/cron.d and in this directory create
a file with the name eachhour . Put the following contents in the
file:
11 * * * * root logger This message is written from
/etc/cron.d
7. Save the modifications to the configuration file and go work on
the next section.

(For optimal effect, perform the last part of this exercise after a
couple of hours.)
8. After a couple of hours, type grep written /var/log/messages
and read the messages that have been written which verifies
correct cron operations.

Exercise 12.2 Scheduling Jobs with at


In this exercise, you learn how to schedule jobs using the atd
service.
1. Type systemctl status atd . In the line that starts with
Loaded:, this command should show you that the service is
currently loaded and enabled, which means that it is ready to
start receiving jobs.
2. Type at 15:00 (or replace with any time near to the time at
which you are
working on this exercise).
3. Type logger message from at . Use Ctrl+D to close the at
shell.
4. Type atq to verify that the job has indeed been scheduled.
End-of-Chapter Labs
In this end-of-chapter lab, you work on at jobs and on cron jobs.
Lab 12.1
1. Create a cron job that performs an update of all software on
your computer every evening at 11 p.m.
2. Schedule your machine to be rebooted at 3 a.m. tonight.

You might also like