Automating tasks saves a system administrator hours of time. It
also keeps the load on the computer and network to a minimum by running
programs off hours. Some of the things you would want to automate would
be backing up file systems, condensing of system logs, restarting the web
server, or emptying out /tmp.
The most common UNIX automation is the cron. The /var/spool/cron is a file that is unique for each user. By default you do not have one. To create a cron type crontab -e (the -e is for edit). The format of this file is very specific. The fields in order are:
minute: 0-59
hour: 0-23 (note military time)
day: 1-31
month: 1-12
weekday: 0-6 (0 is Sunday...)
For example, the follow example will print "Hello world!" to the console everyday at 7 am. Note the * matches all values for that field.
0 7 * * * echo "Hello world!" 2>&1 /dev/console
0 8,9,10 * * * echo "Are you still up?" 2 >1& /dev/console
With the use of a comma the above example prints "Are you still up?"
at 8, 9, 10 am.
The three flags you can use with crontab:
crontab -e ==> Edit/Create your crontab
crontab -l ==> List the entries in your crontab
crontab -r ==> Delete all entries in your crontab file
Note: Super-User can perform any of these operations on anyone's crontab whereas a user can only use them on his/her own crontab file.
at [\\computername] time [/every:date[,...] | /next:date[,...] ] command
to remove a scheduled job at #id number /delete
For example, to run a program called "restart" on yellow everyday at
7am on the 13, 14, and 15 of every month type the following.
at \\yellow 7:00 /every:13,14,15 "restart"