[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28. Reminders

If you're working on a system on a regular basis, it can be very useful to have the system remind you when you should be doing something else. This chapter describes software tools that provide reminders--clocks, calendars, address books, and tools for tracking appointments.

28.1 Displaying the Date and Time  Getting the date and time.
28.2 Playing an Audible Time Announcement  Hearing the current time.
28.3 Calendars  Displaying a calendar.
28.4 Managing Appointments  Keeping track of appointments.
28.5 Contact Managers  Using a contact manager.
28.6 Reminding Yourself of Things  Reminding yourself

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.1 Displaying the Date and Time

@sf{WWW}: http://www.clock.org/
@sf{WWW}: http://www.eecis.udel.edu/~ntp/

Use date to output the current system date and time.

The default format of the output is to display the day of the week; the month name; the day of the month; the 24-hour time in hours, minutes, and seconds; the time zone; and the year.

Use the `-u' option to output the current date and time in Greenwich Mean Time (also known as Coordinated Universal Time, or UTC).

Use the `-R' option to output the date in the format described in RFC822 (see section Word Lists and Reference Files): day of week followed by day of month, month name, year, time, and time zone in numeric format. This is the date format used in email messages.

You can also use the `-d' option to specify the precise fields to output, and the order in which to output them. One useful example is given next; for more information, see the date man page (see section Reading a Page from the System Manual).

To output the number of days into the year for a particular date, use `-d' with 'DD MMM' +%j, where `DD' is the day of month and `MMM' is the name of month.

This command outputs the number 172, which indicates that 21 June of the current year is the 172nd day of the current calendar year.

NOTE: To ensure that the time on your system clock remains as accurate as possible, your system administrator should install the `chrony' package; it periodically adjusts the time on the system clock according to measurements obtained from other servers on the Internet via "Network Time Protocol."

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.2 Playing an Audible Time Announcement

@sf{Debian}: `saytime'
@sf{WWW}: http://www.acme.com/software/saytime/

Use the saytime command to output the current system time in an audible message in a male voice. You must have a sound card installed on your system, and it must be set up with speakers or some other output mechanism at an appropriate volume level in order for you to hear it (see section Adjusting the Audio Controls).

NOTE: If you're feeling adventurous, you can record another voice--like your own--and use that voice instead of the default voice; the sound files used are Sun `.au' files and are kept in the `/usr/share/saytime' directory.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.3 Calendars

The following recipes describe a few of the basic tools for displaying calendars in Linux.

28.3.1 Displaying a Calendar  Displaying a calendar.
28.3.2 Displaying a Calendar in Emacs  Emacs calendar service.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.3.1 Displaying a Calendar

The cal tool outputs a calendar to the standard output. By default, it outputs a calendar of the current month.

To output a calendar for a specific year, give just the year as an option.

Use the `-y' option to output a calendar for the current year.

To output a calendar for a specific month, give both the numeric month and year as arguments.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.3.2 Displaying a Calendar in Emacs

Emacs comes with its own calendar service. The calendar function displays a three-month calendar in a new buffer--it gives the current, previous, and next months, and it puts point on the current date. To select the month and year to display, preface the calendar function with the universal-argument command, C-u.

NOTE: When you display a calendar for a specific month and year, Emacs fills in the current year in the minibuffer; in the example above, the current year was 2001, and BKSP was typed twice to erase the last two digits, which were replaced with `10' to make it the year 2010.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.4 Managing Appointments

@sf{Debian}: `bsdmainutils'

The calendar tool is a reminder service that you can use to manage your appointments. It reads a calendar file, which is a text file in the current directory containing a list of appointments and reminders; then it outputs those entries from the file that have today or tomorrow's date. (On a Friday, it outputs entries for that weekend and for the following Monday.)

For example, if today is Friday, June 16, and you run calendar in the same directory as your calendar file, typical output might look like this:

$ calendar RET
6/16    Finish draft of book
        Party at Jack's
Fri     Lunch with Kim and Jo, 12:30
Mon     Book manuscript due

The calendar tool reportedly first appeared in Version 7 of AT&T UNIX, and was rewritten early on for the BSD family of Unix. While the BSD derivate is available for Debian as part of the bsdmainutils package, this tool isn't yet standard on all Linux distributions.

The following are recipes for writing your calendar files, including other calendar files in your own calendar file, and for automating the delivery of your reminders.

NOTE: Emacs has its own equivalent to this tool, which it calls the "Diary." See Info file `emacs-e20.info', node `Diary' for more information on this feature.

28.4.1 Making an Appointment File  Making an input calendar files.
28.4.2 Including Holidays in Your Reminders  Including other calendars in yours.
28.4.3 Automatic Appointment Delivery  Automating the delivery of your appointments.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.4.1 Making an Appointment File

To begin using calendar, you need to make a "calendar file" where you can enter your appointments. It's just a plain text file, and can be called either `calendar' or `.calendar'; the latter makes it a "hidden" file, as described in Listing Hidden Files.

Write each appointment or calendar entry on a line by itself; blank lines in the file are ignored. The format of a calendar entry is as follows:

[date] [tab or spaces] [text of reminder itself]

Just about every common date style is recognized. For example, the following are all valid dates for the fourth of July:

July 4
4 July
Jul. 4
Jul 4

Entries aren't constrained to a single day, either; you can have entries for a day of the week or for a certain month---`Mon' or `Monday' for every Monday; `Jun' or `June' for the first day of every June. You can use an asterisk as a wildcard: `*/13' reminds you of something on the thirteenth of every month. When the date is omitted on a line, the date of the preceding appointment is assumed.

For example, suppose you have a file called `calendar' in your home directory that looks like this:

6/16    Finish draft of book
        Party at Jack's
6/20    Gallery reading
Fri     Lunch with Kim and Jo, 12:30
Mon     Book manuscript due

If the current date is 16 June, a Friday, and you run calendar in your home directory, you'll get the same output as in the example in the previous section, Managing Appointments.

NOTE: In the example above, the entry for the party doesn't have a date on it--it used the date of the preceding entry, `6/16'.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.4.2 Including Holidays in Your Reminders

The calendar package comes with a collection of prepared calendar files for many kinds of holidays and other occasions, which you can reference in your own calendar file to include their entries in your own reminders.

The prepared files are stored in `/usr/share/calendar'. The following table gives the name of each calendar file and describes its contents.

calendar.birthday Births and deaths of famous people.
calendar.christian Christian holidays.
calendar.computer Significant dates in the history of computing.
calendar.history Dates of U.S. historical events.
calendar.holiday Standard and obscure holidays.
calendar.judaic Jewish holidays.
calendar.music Dates related to music, mostly 1960s rock and roll.
calendar.usholiday U.S. holidays.
calendar.hindu Hindu holidays.

To have calendar output dates from one of these files along with your usual appointments, put the following in your calendar file, where file is the name of the particular calendar file you want to include:

#include <file>

For example, to output both US holidays and famous births and deaths when you run calendar, put these lines somewhere in your calendar file:

#include <calendar.usholiday>
#include <calendar.birthday>

NOTE: You can, of course, share your own calendar files with other users; this is useful for making special calendars for a group or organization. If the calendar file is in the current directory or `/usr/share/calendar', you can just give the file name; otherwise, give its full path name in the include statement.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.4.3 Automatic Appointment Delivery

You can automate your appointment service so that your appointments and reminders are delivered each time you log in or start a new shell, or you can have the day's reminders emailed to you each morning.

Add calendar to your `.bashrc' file to output the day's appointments and reminders every time you log in or start a new shell (see section Customizing Future Shells).

If you keep your calendar file in a directory other than your home directory, make sure that calendar (the tool) is called from that directory. For example, if your calendar file is in your `~/doc/etc' directory, you'd put the following line in your `.bashrc' file:

cd ~/doc/etc; calendar; cd

To have the system send you the day's appointments in email, use crontab to schedule a daily cron job process which runs calendar and, if there is any output, mails it to you with mail.

To do this, add the following line to your `crontab' file (if you don't have one, just put this line in a text file called `crontab' somewhere in your home directory):

45 05 * * 1-5 calendar | mail -s 'Your Appointments' [email protected]

The `45 05 * * 1-5' specifies that these commands be run at 5:45 a.m. on every weekday. The rest of the line is the series of actual commands that are run: the calendar tool is run on your personal calendar file, and if there is any output, it's mailed to [email protected] (replace that with your actual email address, or with your username on your local system if you check mail there).

Add this new crontab entry to the cron schedule by running the crontab tool with the name of your `crontab' file as an argument.

NOTE: The name of the command, crontab, is the same as the file, `crontab'.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.5 Contact Managers

Loosely put, a contact manager is a piece of software that helps you keep track of information about people you may need to contact in the future. In the past, people often called the physical embodiment of these things a "rolodex," which incidentally was a brand name for the Cadillac of such contact managers, the circular Rolodex file that sat atop the desk of every successful 20th century businessman. I hear that many people use them even today; the following recipes show how it can be done in Linux with less desk space and faster search times.

28.5.1 Keeping a Free-Form Address List  A free-form address list.
28.5.2 Keeping a Contact Manager Database  A contact manager database in Emacs.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.5.1 Keeping a Free-Form Address List

The simplest way to keep names and addresses in Linux is to keep them in a text file as a free-form address list; to find an entry, use the search capabilities of tools like grep, less, and Emacs.

This method is useful for when you need to keep track of name and address information of many parties, and don't always keep the same kind of information for each--maybe sometimes a name and phone number, sometimes just a mailing address, sometimes a name and email address. With a free-form address list, each entry contains whatever information you have in the format you want.

Separate the entries with a delimiter line of your preference. I happen to use `###', but you can use whatever characters you're comfortable with--just make it a combination that won't appear in the text for any of the entries themselves.

For example, suppose you have a text file, `rolo', containing three entries:

John Dos Passos
1919 America Ave.
New York City


Scott F. - 602 555 1803
(don't call after 12)


T. Wolfe's new email has changed.
The new one is: [email protected]

Notice that each entry contains varied information, and is in no particular format. That's the benefit of a free-form list--you don't have to type in the entries in any particular order, and you're not bound by a given set of "fields"; you can even cut and paste text into it from email, the Web, or other windows (see section Selecting Text).

There are several ways to find text in such a file. Suppose, for example, you want to contact your friend Scott, and you need his telephone number.

This works nicely when the information you need is on the same line as the information you search for--here, the name Scott is on the same line as the telephone number; however, the output did not show the warning that appears on the next line in the file. And what about when the term you search for and the information you need are on adjacent lines?

Use the `-C' option with grep to output several lines of context before and after matched lines.

Another way to search such a file is to open it as a buffer in Emacs and use any of the Emacs searches. The Emacs incremental-search function, C-s, is very useful for such files--even for very large ones. If you do such a search on a large file, and the first result doesn't turn up the right record, just keep typing C-s until the right one appears. If you type the letters to search for in all lowercase, Emacs matches those letters regardless of case.

You can repeat the second example as many times as you wish to show all entries in the entire buffer with the text `New York' in them. Once you reach the end of the buffer, type C-s again to loop around to the beginning of the buffer and continue the search from there. (The minibuffer will tell you when you've reached the end of the buffer, and will remind you to type this if you want to loop the search.)

NOTE: It's also useful to peruse and search through these kind of files with less---see Searching Text in Less.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.5.2 Keeping a Contact Manager Database

@sf{Debian}: `bbdb'
@sf{WWW}: http://pweb.netcom.com/~simmonmt/bbdb/index.html

The Insidious Big Brother Database is a contact manager tool for use with Emacs. You can use it with Emacs email and news readers; it stores contact information in records, and allows you to search for records that match a regular expression, as well as records whose particular fields match a regular expression (see section Regular Expressions--Matching Text Patterns).

There are several ways to add a record to the database. Use the bbdb-create function to manually add a record (when you run this command, bbdb prompts you to enter the relevant information for each field). When in a mail reader inside Emacs, type a colon (`:') to display the record for the author of the current message; if there is none, bbdb asks whether or not one should be created.

Use the bbdb function to search for records--it takes as an argument the pattern or regexp to search for.

There are additional functions that let you narrow your search to a particular field: bbdb-name, bbdb-company , bbdb-net, and bbdb-notes, which respectively search the name, company, email address, and notes fields.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.6 Reminding Yourself of Things

Sometimes, it's useful to make a reminder for yourself that you'll see either later in your current login session, or the next time you log in. These recipes describe the best ways to do this.

NOTE: When you want to give yourself a reminder for a future appointment, use calendar (see section Managing Appointments).

28.6.1 Sending Yourself Email Reminders  Sending yourself email.
28.6.2 Reminding Yourself When You Have to Leave  Telling you when it's time to go.
28.6.3 Running a Command on a Delay  Running a command on a delay.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.6.1 Sending Yourself Email Reminders

Sending yourself a short email message is often effective for reminding yourself to do something during your next workday or next time you read mail; keeping a message in your INBOX works as a constant reminder to get something done--provided you don't abuse it and fill your INBOX with lots of these "urgent" mails!

To quickly send an email reminder, give your email address (or just your username on your local system, if you check mail there) as an argument to mail tool. You'll be prompted to give a subject for the message, and if that isn't enough space for the reminder, you can write as many lines as you need below it as the message body text; type C-d on a line by itself to send the mail.

NOTE: For more about using the mail tool, see Sending Mail.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.6.2 Reminding Yourself When You Have to Leave

@sf{Debian}: `leave'
@sf{WWW}: http://www.debian.org/Packages/stable/utils/leave.html

Use the leave tool to remind yourself when you have to leave. Give as an argument the time when you have to go, using the format of hhmm, where hh is hours in 24-hour format and mm is minutes.

When you run leave with no arguments, it prompts you to enter a time; if you just type RET then leave exits without setting the reminder. This method is good for adding leave to scripts or to your `.bashrc', so that you may interactively give a time to leave, if desired, when the script runs (see section Customizing Future Shells).

NOTE: leave will output a reminder on the terminal screen five minutes before the given time, one minute before the time, at the time itself, and then every minute subsequently until the user logs off.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.6.3 Running a Command on a Delay

The sleep tool does nothing but wait (or "sleep") for the number of seconds specified as an argument. This is useful for ringing the system bell, playing a sound file, or running some other command at your terminal after a short delay.

To do this, give the number of seconds to "sleep" for as an argument to sleep, followed by a semicolon character (`;')(36) and the command(s) to run. This runs the given command(s) only after sleep waits for the given number of seconds.

Since the shell where you type this command will be unusable until the commands you give are executed (or until you interrupt the whole thing), type this command in an xterm or virtual console window (see section Console Basics) other than the one you are working in.

You can also give the time in minutes, hours, or days. To do this, follow the argument with a unit, as listed in the following table.

s Seconds.
m Minutes.
h Hours.
d Days.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html