Changes

Jump to: navigation, search

Lab 5 Warnings / Debrief

1,564 bytes added, 08:23, 8 July 2015
no edit summary
Cron Tables (crontabs) allow the Linux System Administrator to run useful shell scripts or shell script that we have created at specific dates/times. It would be silly to expect a system administrator to stay up late (eg. 2 a.m.) to manually run a shell script to terminate processes or to re-boot Linux servers. Database files (tables) are used to provide instructions on how frequent shell scripts or commands can be run. The '''cron''' daemon is used to refer to these files and to run them on a pre-determined basis. The term '''cron''' comes from the old word '''chronograph''' meaning a special type of watch (actually a ''stop-watch'') to help monitor and schedule routine tasks.
Scheduling commands, shell scripts, or other programs to be run are contained in a file called: '''/etc/crontab'''. This file stores the list of jobs to do that are run on a particular schedule. This file cannot be edited manually via a text editor. Instead, the '''crontab''' utility is used to create, edit and remove that file. Here some ways to use the crontab utility: Crontab utility is very easy to use. '''crontab -e''' (creates or edits crontab file)'''crontab -u username -e''' (for specified user)'''crontab -l''' (lists current crontab file)'''crontab -r''' (remove crontab file) Here is the typical field layout for a crontab entry (or multiple entries): .---------------- minute (0 - 59) | .------------- hour (0 - 23)| | .---------- day of month (1 - 31)| | | .------- month (1 - 12) (or jan,feb,mar,apr ...) | | | | .---- day of week (0 - 6) (Sunday=0 or 7) | | | | | (or sun,mon,tue,wed,thu,fri,sat)| | | | |* * * * * command to be executed  The asterisks indicate to run for that unit of time. Below is an example of crontab entries:  # Check every minute for logins by user “evil”'''* * * * * who | grep '^evil''''# # Run a script called "ascript.bash" every odd hour (1,3 5...) during the week'''0 1,3,5,7,9,11,13,15,17,19,21,23 * * 1-5 /home/bob/ascript.bash'''# Run "ascript.bash" every half hour during the week'''0 */2 * * 1-5 /home/bob/ascript'''# Same... just doing it a different way'''0 */2 * * mon,tue,wed,thu,fri /home/bob/ascript''' You will learn in the lab how to create and use crontabs the crontab utility to run periodically a shell script automatically and periodically that will send an e-mail warning to the system administrator if disk space capacity has reached a level for immediate resolution.
13,420
edits

Navigation menu