Linux系统邮件查看及清空

Linux/Shell 2012-07-26 Linux,邮件

在操作Linux命令时,时常出现以下这样一句话

You have mail in /var/spool/mail/root

这个是提示有最新的邮件,你可以使用mail命令阅读

-bash-4.1# mail 
Heirloom Mail version 12.4 7/29/08.  Type ? for help.
"/var/spool/mail/root": 383 messages 381 unread
    1 user@localhost.local  Tue Apr 10 20:09 183/7743  "[abrt] full crash report"
>U  2 user@localhost.local  Tue Apr 10 20:15 183/7730  "[abrt] full crash report"
 U  3 user@localhost.local  Tue Apr 10 20:20 183/7730  "[abrt] full crash report"
 U  4 user@localhost.local  Tue Apr 10 20:22 183/7730  "[abrt] full crash report"

然后使用n 编号查看相应邮件,如查看编号为4的邮件

& n 4
Message  4:
From user@localhost.localdomain  Tue Apr 10 20:22:07 2012
Return-Path: <user@localhost.localdomain>
X-Original-To: root@localhost
Delivered-To: root@localhost.localdomain
Date: Tue, 10 Apr 2012 20:22:07 +0000
From: user@localhost.localdomain
To: root@localhost.localdomain
Subject: [abrt] full crash report
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
Status: RO

Duplicate check

使用q键退出mail系统

& q
Held 384 messages in /var/spool/mail/root
You have mail in /var/spool/mail/root
-bash-4.1# 

当然,里边都是一些无关紧要的邮件,我们也可以清空,清空很简单,只需要进入/var/spool/mail就好

-bash-4.1# cd /var/spool/mail/

列出了所有用户的邮件

total 14560
-rw-rw---- 1 li** mail     6774 May 18 17:17 lizhong8532
-rw-rw---- 1 mysql       mail        0 Apr 23 16:58 mysql
-rw------- 1 root        mail 14880366 Jul 26 13:50 root
-rw-rw---- 1 www         mail        0 Apr 23 18:23 www

删除邮件,比如删除root的邮件,只需要写空就好,最好别删除,否则容易出错

-bash-4.1# echo ''>root 
You have mail in /var/spool/mail/root
-bash-4.1# ll
total 12
-rw-rw---- 1 li** mail 6774 May 18 17:17 lizhong8532
-rw-rw---- 1 mysql       mail    0 Apr 23 16:58 mysql
-rw------- 1 root        mail    0 Jul 26 13:54 root
-rw-rw---- 1 www         mail    0 Apr 23 18:23 www

这样即可删除烦人的邮件提示了,虽然执行echo ''>root命令会提示You have mail in /var/spool/mail/root但实际上邮件内容已经清空,当root文件发生改动,一律都提示You have mail in /var/spool/mail/root

文字链接:《Linux系统邮件查看及清空

文章地址:http://www.qttc.net/201207145.html

除非标注,琼台博客所有博文均为原创,转载请加文字链接注明来源

乳名?小名?昵称?网名?均可

email,放心,我不会给你乱投广告的

想获得回访就把你的站点URL写上(没有留空)

[NOTICE]木要投放广告
[NOTICE]木要骂人,说不该说的话
[NOTICE]自由言论,但要遵纪守法

Comments 3

  • 一直不明白为什么mail命令的delete一直无效呢
    2015-06-11 11:03:26 [ 跟帖 ]
    1 #
  • 我觉得你应该给网站加个副标题。写明你的网站主题。
    2012-07-26 14:36:26 [ 跟帖 ]
    加上了,副标题有利于SEO,呵呵!
    2012-07-26 15:03:59 [ 跟帖 ]
    2 #