[comp.unix.admin] mail notification at login

allen@nntp-server.caltech.edu (Scott R. Allen) (02/07/91)

Hello -

I am experiencing an anomoly with mail that I don't quite
understand and I would greatly appreciate it if someone could
explain this to me.  Here is the scenario:

Sun workstation --SunOS version 4.1

1.  Root sends mail to user1.
2.  User1 logs in and gets the 'you have new mail' message.
3.  User1 logs out.
4.  User1 logs in again and gets the same 'you have new mail' message.
5.  User1 logs out.
6.  Root executes the command 'cat /var/spool/mail/user1' and the
    all of the mail in user1's folder scrolls on the screen, the
    message that root sent being the last.
7.  User1 logs in again and this time gets the message 'you
    have mail' rather than 'you have new mail'.

The only thing that has happened between step 4 and step 7 is 
that root has done a cat on user1's mail folder.  My question is:
WHY does this happen?  How does it now that the file has been
read by someone and why does it change the message from 'you have
new mail' to 'you have mail'?  

It is my understanding that this test for mail is internal to
the 'login' program.

Note:  A probably unrelated detail -- If this is the first time
that user1 has ever gotton mail (when root sends it in step 1)
and therefore user1 doesn't have a /var/spool/mail/user1 file
then it is created at step 1.  Oddly enough, if this is the case
then in step 2 when user1 logs in the message only says 'you
have mail' rather than 'you have new mail'.  I assume that this
is a bug.  To get around this, root sends user1 two mail messages
or someone else has previously sent user1 mail.

If someone can explain how 'login' decides between 'you have mail'
and 'you have new mail' I would really appreciate it.

thanks

Scott Allen
allen@tybalt.caltech.edu

jik@athena.mit.edu (Jonathan I. Kamens) (02/07/91)

  See my answer to this question in comp.unix.misc (and *please* don't
discuss the question in multiple newsgroups!).

  I wish people would learn to cross-post and use Followup-To: headers
before posting messages to multiple newsgroups....

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710

allen@nntp-server.caltech.edu (Scott R. Allen) (02/07/91)

Thanks for all of the replies -- I now understand how to compare
the 'access' time stamp for a file vs. the 'modify' timestamp
for a file.

Scott