Topic 8

Dates: 3/8/2017
Start-up and Run Levels. Scheduled jobs (at, cron)
Linux System Administration


Practical Exercises with at and cron

Complete the exercises below on run01 VM

Install package at:
apt-get install at
As user hostadm, Create script, mem.sh, to check memory status:
#!/bin/sh
# Checks memory status through cron

of=/home/hostadm/mem.out
dt=`date`

echo "Memory status (in MB) on $dt:" >> $of 
free -m >> $of
echo "------------------" >> $of 
Make it executable
chmod 755 mem.sh
and run through at:
at -f mem.sh now + 1 minute
Run atq to make sure the job is scheduled. In a minute, check content of a new file, mem.out; run atq again.

Remove file mem.out. Add the following entry in /etc/crontab below the other scheduled tasks:
*/2 * * * *  root  /home/hostadm/mem.sh 
Check if the content of mem.out is updated every 2 minutes.


Take me to the Course Website