CS 279 - Week 14 Lab - 11-28-12
crontab
* utility; described on pp. 246-248 of course text
* for specifying that a job be run on some regular
basis
* originally for administrative tasks,
BUT some systems allow individual users to use,
also, and nrs-project does indeed do so
* you can't reach this crontab "directly" --
you must reach it using the crontab utility
crontab -e
...will create and open your crontab for editing
(if it already exists, it'll open it for
editing)
* default editor is vi
BUT if you change the EDITOR environment
variable, you can change that
export EDITOR=/usr/bin/emacs
* ONLY jobs to be scheduled and comments go in
this file; <-- crontab entry
a "comment" in a crontab file either is a
completely blank line, OR it starts with
a # in column 1
a job to be scheduled has 6 fields, separated
by whitespace:
field 1 - 0-59, minute
field 2 - 0-23, hour
field 3 - 1-31, day of the month
field 4 - 1-12, month of the year
field 5 - 0-6, day of the week, 0=Sunday
can have a * for any one of the fields 1-5,
and that represents ALL the valid values
* field 6 - consists of a command followed
(optionally) by the "lines" that the command
expects to read from standard input
...but a crontab entry has to be on a single
line! You kluge this by putting % where a
newline would go (between the command and
its standard input, at the end of a standard
input "line")
you can \% to get a percent character in your
command
* I've found (not having experimented with PATH
options) that I've needed to put absolute
pathnames for files involved in crontab
entries;
...I thought I needed absolute pathnames
for commands, too, but now I'm not so sure;
crontab does seem to expect you to end the
last crontab entry with a <newline> (typing
enter at the end of it)
* crontab -l
...lists the current contents of your crontab
file
* crontab -r
...removes your crontab file