calendar
Display upcoming events from calendar file
TLDR
Show events for today and tomorrow (or the weekend on Friday) from the default calendar
Look [A]head, showing events for the next 30 days
Look [B]ack, showing events for the previous 7 days
Show events from a custom calendar [f]ile
SYNOPSIS
calendar [-t month] [-A num] [-B num] [-f file] [-l num] [-w num] [-a] [-u] [-N] [-n] [-s]
PARAMETERS
-A num
Displays entries scheduled for num days after today, inclusive.
-B num
Displays entries scheduled for num days before today, inclusive.
-f file
Specifies an alternative calendar file to read instead of the default ~/calendar.
-l num
Displays entries for num days, starting from today. This overrides the default 'today and tomorrow' behavior.
-w num
Displays entries for num days after today (similar to -A num).
-a
Processes all calendar files found in a system-wide directory (e.g., /etc/calendar) rather than just the user's home directory file.
-u
Uses Coordinated Universal Time (UTC) for date calculations instead of local time.
-N
Suppresses normal output; only reports syntax errors found within the calendar file(s).
-n
Processes the calendar file for US holidays. The exact behavior may depend on system configuration and the presence of specific holiday definitions.
-s
Suppresses error messages, running the command in silent mode.
-t month
(Debugging) Treats the specified month as the current month for date matching purposes.
DESCRIPTION
The calendar command acts as a personal reminder utility in Unix-like systems. It operates by reading a user-defined plain text file, typically named calendar and located in the user's home directory (~/calendar). The core function of the command is to scan this file for lines that contain dates matching today's or tomorrow's date, along with recognized holidays. When such matches are found, the corresponding lines are displayed to the standard output, effectively reminding the user of upcoming events.
The flexibility in date parsing allows for various formats within the calendar file, including 'Month Day', 'MM/DD', and special keywords like 'holiday' or day abbreviations. Beyond its default behavior, calendar offers a range of options to customize its operation. Users can specify an alternative calendar file, adjust the range of days to check (e.g., several days before or after the current date using -A or -B), process system-wide calendar files using -a, or even use UTC for time calculations with -u. It's commonly automated via cron jobs to send daily reminders, providing a simple yet effective tool for managing personal schedules without the overhead of more complex calendaring applications.
CAVEATS
The calendar command relies on a plain text calendar file, which requires manual maintenance and adherence to specific date formats for correct parsing. Its date parsing can be susceptible to locale settings and year ambiguity, especially for events spanning multiple years or specific recurring dates. It does not support complex scheduling features like event durations, multiple time zones (beyond the -u option), or direct integration with graphical calendaring systems. The default calendar file location (~/calendar) might vary slightly across different Unix-like distributions.
<B>CALENDAR FILE FORMAT</B>
The calendar command reads a plain text file, typically named calendar. Each line in this file represents an event or reminder. Dates are usually placed at the beginning of the line, and the command is flexible in recognizing various formats such as 'January 1', '1/1', '1 Jan', or '01/01'. It also recognizes specific day names like 'Mon', 'Tue' for weekly reminders, and keywords like 'holiday'. Lines beginning with a '#' character are treated as comments and ignored.
The command performs a case-insensitive match, and leading zeros in dates are generally disregarded. This simplicity makes the calendar file easy to create and maintain manually, allowing users to quickly add or modify their reminders.
<B>TYPICAL USAGE WITH CRON</B>
While calendar can be run manually, its power is often realized when combined with the cron daemon for automated execution. Many users set up a daily cron job to run calendar (e.g., at login or early morning). The output of the command is then typically emailed to the user or displayed upon login, providing a daily digest of upcoming events and reminders. This integration transforms calendar from a simple command-line tool into a passive, yet effective, personal assistant.
HISTORY
The calendar command is one of the oldest utilities in Unix-like systems, tracing its roots back to early BSD distributions. Its design reflects the simplicity and efficiency characteristic of early Unix tools. While more sophisticated calendaring applications exist today, calendar remains a lightweight and accessible tool, often used in cron jobs to provide daily reminders without requiring user interaction. It exemplifies the Unix philosophy of creating small, specialized tools that perform one function exceptionally well.