root:yourusername
newaliases).No, that is not the unix classic way.The classic way of handling mails on a Unix system: mail/fetchmail ...
mail(1) command. Still works that way.How did people retrieve their emails before that?
Reading Mail
In normal usage mail is given no arguments and checks your mail out of
the post office, then prints out a one line header of each message
found. The current message is initially the first message (numbered 1)
and can be printed using the print command (which can be abbreviated
p). You can move among the messages much as you move between lines in
ed(1), with the commands + and - moving backwards and forwards, and
simple numbers.
Two per day (daily run, daily security). And one every week (weekly run), and another one every month (monthly run).is it constantly appended to?
/var/mail/* are the users mail spool (and not log files) - of course the operating system won't delete anything there. (But as already written you could use a MUA to delete them; also you could simply truncate the file - but your wish was to keep the last month…)My question was not about accessing it but whether it gets added to adinfiinittum.
If mails from your 'public' mailaccount end up in /var/mail/root you are doing something *very* wrong...I wrote about receiving mails from your ISP etc. - I know the mail command only to handles the local mail spool (and that's where fetchmail came in). I vaguely remember that there was another way to access your mailbox at your ISP in order to "correct" something via "mail". But that wasn't common practice…
Yes. Or rlogin / rsh. Also pop is old and you could retrieve with with fetchmail, but that was, as far as I know, not standard.My experience only goes back to the mid/late 90s; Unix is older than that… How did people retrieve their emails before that? Read them via telnet?
Mails are there to be read. After reading them, you can delete them with 'd' in mail program.My question was not about accessing it but whether it gets added to adinfiinittum.
You can delete all of them withyou can delete them with 'd' in mail program.
d*Or the first 10 with: d1-10You can delete all of them withd*
#!/bin/sh
DL=$(date -j -v -1m +%Y%m%d)
while true
do
did=0
D=""
D=$(head -100 /var/mail/root|grep ^Date: |head -1|sed -e 's/^Date: .*, //')
[ "X$D" = "X" ] && exit
DD=$(date -j -f "%d %b %Y %T %z" "$D" +%Y%m%d)
if [ "$DD" \< "$DL" ]
then
echo del msg from $DD
echo -e "d1\npre"|mail >/dev/null
did=1
else
echo "ND $DD $D"
fi
[ $did -eq 0 ] && break
done
Not the case and didn't wrote that.If mails from your 'public' mailaccount end up in /var/mail/root you are doing something *very* wrong...
Unless you go to some effort to redirect it, the default setup is that mail for root is stored in that file. And, as SirDice already said, at least the output of the periodic jobs is added to it every day, week and month.Is there any automatic housekeeping on /var/mail/root or is it constantly appended to?
To my knowledge, there is no such script. It would be possible to write one, at worst by using expect and the default mail program.I'd like mail older than a month to be deleted automatically. Maybe there is some process which does this... perhaps a periodic script...