Lesson 7

Dates: 3/5/2014
Start-up and Run Levels. Scheduled jobs (at, cron)
Linux for Engineering and IT Applications


Practical Exercises with at and cron

Complete the exercises below on run01 VM

Create a script, mem.sh, to check memory status:
#!/bin/sh
# Checks memory status through cron

of=/home/$USER/mem.out
dt=`date`

echo "Memory status (in MB) on $dt:" >> $of 
free -m >> $of
echo "------------------" >> $of 
Make it executable 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. Modify the script specifying the full path to your home directory in "of", i.e. "of=/home/your_username/mem.out". Add the following entry in /etc/crontab before the line "# run-parts":
*/2 * * * *  root  /home/your_username/mem.sh 
Check if the content of mem.out is updated every 2 minutes.


Take me to the Course Website