|[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]|
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.
WWW: http://www.clock.org/ WWW: http://www.eecis.udel.edu/~ntp/
date to output the current system date and time.
$ date [RET] Fri May 11 11:10:29 EDT 2001 $
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).
$ date -u [RET] Fri May 11 15:10:29 UTC 2001 $
Use the `-R' option to output the date in the format described in RFC822 (see 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.
$ date -R [RET] Fri, 11 May 2001 11:10:29 -0400 $
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
(see 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.
$ date -d '21 Jun' +%j [RET] 172 $
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."
Debian: `saytime' WWW: http://www.acme.com/software/saytime/
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 Adjusting the Audio Controls).
$ saytime [RET]
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.
The following recipes describe a few of the basic tools for displaying calendars in Linux.
cal tool outputs a calendar to the standard output. By
default, it outputs a calendar of the current month.
$ cal [RET]
To output a calendar for a specific year, give just the year as an option.
$ cal 2001 [RET] 2001 January February March S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 3 4 5 6 1 2 3 1 2 3 7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10 14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17 21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24 28 29 30 31 25 26 27 28 25 26 27 28 29 30 31 April May June S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 3 4 5 6 7 1 2 3 4 5 1 2 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9 15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16 22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23 29 30 27 28 29 30 31 24 25 26 27 28 29 30 July August September S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 3 4 5 6 7 1 2 3 4 1 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8 15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15 22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22 29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29 30 October November December S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 3 4 5 6 1 2 3 1 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8 14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15 21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22 28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29 30 31 $
Use the `-y' option to output a calendar for the current year.
$ cal -y [RET]
cal -y | lpr [RET]
To output a calendar for a specific month, give both the numeric month and year as arguments.
$ cal 06 1991 [RET] June 1991 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 $
Emacs comes with its own calendar service. The
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
function with the
universal-argument command, C-u.
$ M-x calendar [RET]
C-u M-x calendar [RET] Year (>0): 2001 [BKSP] [BKSP] 10 [RET] Month name: Aug [RET]
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.
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
the same directory as your calendar file, typical output might look like
$ calendar [RET] 6/16 Finish draft of book Party at Jack's Fri Lunch with Kim and Jo, 12:30 Mon Book manuscript due $
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
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.
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:
7/4 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
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'.
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
The prepared files are stored in `/usr/share/calendar'. The following table gives the name of each calendar file and describes its contents.
||Births and deaths of famous people.|
||Significant dates in the history of computing.|
||Dates of U.S. historical events.|
||Standard and obscure holidays.|
||Dates related to music, mostly 1960s rock and roll.|
calendaroutput 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
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.
calendar to your `.bashrc' file to output the
day's appointments and reminders every time you log in or start a new
shell (see 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
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
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@example.com
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
firstname.lastname@example.org (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
crontab tool with the name of your `crontab' file as an
$ crontab crontab [RET]
NOTE: The name of the command,
crontab, is the same as
the file, `crontab'.
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.
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
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@example.com
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 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.
$ grep -i scott rolo [RET] Scott F. - 602 555 1803 $
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.
$ grep -C olfe rolo [RET] T. Wolfe's new email has changed. The new one is: firstname.lastname@example.org $
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
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.
C-s new york
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.
Debian: `bbdb' 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 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
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
bbdb asks whether or not one should be created.
bbdbrecord from scratch, type:
M-x bbdb-create [RET]
bbdbrecord for the author of the current email message, type:
bbdb function to search for records -- it takes as an
argument the pattern or regexp to search for.
M-x bbdb [RET] scott [RET]
There are additional functions that let you narrow your search to a
bbdb-notes, which respectively search the
name, company, email address, and notes fields.
M-x bbdb-net [RET] *\.edu [RET]
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
calendar (see Managing Appointments).
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
joe, to send yourself an email reminder, you'd type:
$ mail joe [RET] Subject: Bring files to meeting [RET] C-d Cc: [RET] Null message body; hope that's ok $
NOTE: For more about using the
Debian: `leave' WWW: http://www.debian.org/Packages/stable/utils/leave.html
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.
$ leave 2005 [RET]
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 Customizing Future Shells).
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
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
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 Console Basics) other than the one you are working
$ sleep 5; echo -e '\a' [RET]
$ sleep 30; saytime [RET]
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.
$ sleep 5m; saytime & [RET]
[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]