RHCSA Rapid Track
In this lab, you will work with recurring system jobs.
| Resources | |
|---|---|
| Files: |
|
| Machines: | desktopX |
Outcomes
A daily job to count the number of active users, and an updated cron job to gather system performance data.
Log into your
desktopXsystem asstudent, then elevate your privileges toroot.[student@desktopX ~]$su -Password:redhat
Create a new daily cron job that logs a message to the system log with the number of currently active users (w -h | wc -l). You can use the logger command to send messages to the system log.
Open a new file in
/etc/cron.dailyin an editor, e.g.,/etc/cron.daily/usercount.[root@desktopX ~]#vim /etc/cron.daily/usercountWrite the script that logs the number of active users to the system log.
Insert the following in your editor:
#!/bin/bash USERCOUNT=$(w -h | wc -l) logger "There are currently ${USERCOUNT} active users"Make the script executable:
[root@desktopX ~]#chmod +x /etc/cron.daily/usercount
The sysstat package, when installed, has a cron job that runs every 10 minutes, collecting data using a command called sa1. Make sure this package is installed, then change this job to run every five minutes.
Make sure the sysstat package is installed.
[root@desktopX ~]#yum -y install sysstatFind out in which file the sysstat package has configured the cron jobs. Cron jobs are generally configured in files marked as a configuration file for the package manager.
[root@desktopX ~]#rpm -qc sysstat/etc/cron.d/sysstatlooks promising.Open
/etc/cron.d/sysstatin an editor.[root@desktopX ~]#vim /etc/cron.d/sysstatChange
*/10on thesa1line to*/5.Save your changes and exit.
Monitor the files in
/var/log/sato see when their sizes and timestamps change.[root@desktopX ~]#watch ls -l /var/log/sa