Depending on how your system is set up, you may notice that it
periodically says something like
The shell normally checks your mailbox every five minutes. However, you can set a different interval at the start of the list. For example, the command below tells the shell to check my mailbox every 60 seconds:
Note that the exact filename depends upon how your mail system is set up. For example, many systems use /usr/mail instead of /usr/spool/mail . Checking for mail takes time and can delay your prompt on busy systems. Don't set a short interval unless you need to.
Many users need to watch more than one mailbox. For example, I need to watch /usr/spool/mail/mikel ; but if I'm responsible for product support, and my company maintains a special mail ID for support questions, I might also want to watch /usr/spool/mail/prodsupport . To do this, we set the mail variable so that it's a list of important files and directories:
When the list has more than one file, the shell will tell you which file
has changed with a message like
All mail is doing is looking to see whether or not the file has changed; it doesn't know that it's looking at a "mail" file. Therefore, you can use it to watch anything you want; your list can even include directories. For example, let's say that you're running a program that periodically writes to the file /home/los/mikel/radio/log.out . Then you can set mail as follows:
Watching a directory is
the same as watching a file; you'll be notified whenever the directory
changes (whenever a file is
added or deleted in the directory). So let's modify our previous example
slightly; let's say that your reports are named
Here's another example. Let's say that you suspect someone is usingto send company secrets to a system named somewhere . You want to watch this systems's UUCP traffic very carefully. To do so, you can tell the shell to inform you whenever the logfile changes:
We've told the shell to check the log every five seconds because, given that we suspect security problems, we want to get our reports immediately.
Now, let's assume that you're a Bourne shell user, and go through everything once more. The Bourne shell uses three variables to control mail notification. (These are usually set in users' files. To make them work in , the variables.) We'll assume that you read the C shell description already given, and move a bit faster.
First, if you want to check only one file or directory, set the variable MAIL accordingly.
By default, the Bourne shell checks every ten minutes. To check at some other interval, set the variable MAILCHECK to your new interval, in seconds: for example, the command below tells the shell to check every 55 seconds:
One useful trick: if you set
to 0, the shell will check
whenever it prints the "primary" prompt (by default,
If MAILPATH is set, the shell will ignore the MAIL variable. You can't use both.
the Bourne shell prints
You can create a different message for every file that you care about.
Note that the Korn shell and