UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 40.10 nextday, nextweekday: Tomorrow or Next Weekday Chapter 40
Delayed Execution
Next: 40.12 Periodic Program Execution: The cron Facility
 

40.11 Send Yourself Reminder Mail

I use the at command (40.7) to send myself reminders. The at job runs a mail program (1.33) and feeds the body of the message to the mailer's standard input. Examples:

  1. To send a one-line reminder, I use a one-line command like this:

    % at 0427 tuesday
    at> echo "send summary to Tim today" | mail jpeek@jpeek.com
    at> [CTRL-d]
    %

    It sends mail at (in this case) 4:27 a.m. on the next Tuesday. The mail says: "send summary to Tim today."

  2. To send more than one line, you can use a temporary file:

    % vi msgfile
       ...put message body in msgfile...
    % at 0808 feb 28
    at> mail jpeek@jpeek.com < msgfile
    at> rm msgfile
    at> [CTRL-d]
    %

  3. Combine the output of UNIX commands and text with backquotes (9.16) and a here document (8.18):

    % at 0115
    at> mail -s "Hard-working people" tom << END
    at> These employees are working late. They deserve a bonus:
    at> `w`
    at> END
    at> [CTRL-d]
    %

    That sends a message to tom at 1:15 a.m. tonight. (This mailer accepts a subject on the command line with its -s option. The output of the w command gives detailed information about logged-in users; not all systems have it.) Unless you understand how to quote here-document text (45.26), the message shouldn't have anything but letters, numbers, commas, and periods.

If your system administrator has set up the calendar (48.4) program, it's good for easy one-line reminders on particular days. If your UNIX has personal crontabs (40.12) that can send periodic reminders every Tuesday, every hour, or whatever: use the commands in items 1 or 2 above.

- JP


Previous: 40.10 nextday, nextweekday: Tomorrow or Next Weekday UNIX Power ToolsNext: 40.12 Periodic Program Execution: The cron Facility
40.10 nextday, nextweekday: Tomorrow or Next Weekday Book Index40.12 Periodic Program Execution: The cron Facility

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System