[ic] IC Jobs question
Geoff Sternecker
geoffs at rdgi.com
Wed Oct 22 22:04:43 EDT 2003
found via 15 seconds on Google: Credit to the Authors, Not Me, Probably credit
to RedHat..
Cron
Cron is a handy little utility that helps the system administrator automate
repetative tasks.
Cron is controlled by a set of files called "crontabs". There is the master
file in /etc/crontab (which in Red Hat Linux is set up a little different
than other *nixes), along with crontab files for the users in
/var/spool/cron/. In the latter directory, the files are given the same name
as a user's login ID.
Crontab location:
/var/spool/cron
/etc/crontab
In Red Hat Linux, it is a little easier for the sysadmin to set up cron jobs
than in other distributions. The /etc/crontab file automatically executes
items in several subdirectories at regular periods.
/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly
All the sysadmin needs to do is drop a shell script or a link to an executable
in one of the directories and it will automatically be run at the appropriate
time.
Setting up a user-level crontab is somewhat different. The files in
/var/spool/cron are not edited directly. Instead, a program called "crontab"
is used to manipulate them. Depending on system security, all users, only
some, or just the root user will be able to use crontab (see man crontab
/etc/cron.allow and /etc/cron.deny for more information). SYNOPSIS crontab [
-u user ] file
crontab [ -u user ] { -l | -r | -e }
file store the specified file as the current crontab
-u user the crontab file being manipulated is for
-l display the current crontab
-r remove current crontab
-e edit the current crontab (editor depends on system
variables and will probably be vi unless your sysadmin
has changed it).
If you are not familiar with the systemwide default editor, it is probably
best to create/edit the file with one you are familiar with and use the file
option with the first command.
Crontab configuration: Blank lines, leading spaces, and tabs are ignored.
Lines that start with a # are comments and are ignored. Comments are not
allowed to be on the same line as cron commands; they will be assumed to be
part of the command. Comments are not allowed on the same line as environment
settings for similar reasons.
Syntax
Environment settings take the format of
name = value
(The spaces around the = are optional.)
Each cron command has 5 time and date fields, followed by a user name, and if
this is the system crontab file, it will be followed by a command. Commands
are
executed when the time specified by the time/date fields matches the
current time.
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 0-31
month 0-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
A field may be an asterisk (*), which always stands for ``first to
last''. So used in the hour field, it means 'every hour from 00:00 to
23:00"
Example Crontab:
# r----minute
# | r-----hour
# | | r------day of the month
# | | | r------month
# | | | | r------day of the week
# | | | | | |------ command to run ------------->
# | | | | | |
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run five minutes after midnight, every day
15 14 1 * * $HOME/bin/monthly
# run at 2:15pm on the first of every month -- output mailed to paul
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
# print out the message at 4:05 every sunday.
5 4 * * sun echo "run at 5 after 4 every sunday"
If this file were saved as "paul.ct" then
crontab -u paul paul.ct
would be used to store the crontab for the user paul.
More information about the interchange-users
mailing list