48.4 Automatic Reminders and More: calendarIf you type the command calendar , you'll see lines with "to-do" items for today and tomorrow from a file named calendar in your current directory. If you put that file in your home directory, your system administrator can run the command calendar -to mail (1.33 ) everyones' "to-do" items to them. You can also automate your personal calendar setup by running calendar yourself - the calendar can be mailed to you, sent to the printer, and so on, first thing each morning. See below for an example calendar file and more information. calendar builds a complicated egrep (27.5 ) expression to search your calendar file. You can see that expression yourself if you want to. 48.4.1 How calendar WorksLet's start by showing a few lines of a sample calendar file. (Yours can be much longer.) Then I'll run calendar to show what lines it picks: %
Today is December 8.
The calendar
utility found lines in my calendar
file for
today and tomorrow.
calendar
understands lots of date formats.
The date can be anywhere on a line.
If you leave a line in your file for more than one year (like Mom's
birthday) calendar
will show it every year.
If a line has more than one date, you'll see the line on both of those
dates (I'll be reminded before Mom's birthday and also in time to make a
dinner reservation).
An asterisk ( Many versions of calendar
utility run your calendar
file
through the C language preprocessor, cpp
.
Among other things, this lets you include
several calendar files in your own calendar file.
Lines that start with a hash mark ( #include "/usr/local/lib/office.calendar"
Someone (the office secretary) can maintain the office.calendar
file.
People in the office who want reminders from it can put the
By the way, if you start a line with 48.4.2 The egrep Expression calendar UsesHow can calendar
find dates in all the formats it accepts - and
only for today and tomorrow?
It runs a system program, usually named /usr/lib/calendar
,
that generates an expression for
egrep -f
(27.7
)
.
The expression searches for the dates of today and tomorrow; if
today is a Friday, the expression includes dates on Saturday, Sunday, and
Monday.
Here's the expression I got by running /usr/lib/calendar
on Tuesday, December 8.
TAB characters are shown as % I'll turn the first line of that into English.
I'm not writing this just for egrep
fanatics
Whew. That expression is repeated for every other day that needs to be matched. On Fridays, the output of /usr/lib/calendar has four lines - one each for Friday, Saturday, Sunday, and Monday. 48.4.3 Automating Your Own CalendarIf you want a calendar every weekday, put a line like the following into your personal crontab file (40.12 ) . We've split this onto two lines for printing, but you should type it all on one line:
That runs calendar
from my home directory at
6:06 a.m. (40.5
)
every weekday morning.
It sets a
Bourne shell variable (6.8
)
named tf
with the name of a temporary file in the
/tmp
directory (21.3
)
,
and sets a
umask
(22.4
)
to make the file private.
Then it runs calendar
and saves the output in the temporary file.
If there's a calendar for today, the mail
command sends the file
to me.
(The -s
option on our mail
command adds the If you don't have personal crontab s, you can use a self-restarting at job (40.8 ) and the nextweekday script (40.10 ) instead. - |
|