zoukankan      html  css  js  c++  java
  • Linux出现You have new mail in /var/spool/mail/root提示,关闭邮件提示清理内容的解决方案

    Linux出现You have new mail in /var/spool/mail/root提示,关闭邮件提示的解决方案

    有的时候敲一下回车,就出来You have new mail in /var/spool/mail/root的提示。
    原因是Linux系统经常会自动发出一些邮件来提醒用户系统中出了哪些问题(收件箱位置:/var/mail/),比如crontab里面的脚本命令执行错误了(sh文件名,python命令没有使用全路径,没有使用后台运行nohup命令等问题导致无法正常执行的报错)。
    LINUX会定时查看各种状态做汇总,每经过一段时间会把汇总的信息发送到root的邮箱里。
    一般这种情况mail的内容就只是一些正常的系统信息或者是比较重要的错误报告。

    centos默认安装有sendmail的,可以使用mail命令查询(要退出时输入q加回车)

    如果安装了mutt可以用mutt命令查看mail的内容,没有装用系统命令:cat /var/spool/mail/root查看。

    ----------------

    要关闭提示的解决方案:
    第一步:关闭提示
    echo "unset MAILCHECK">> /etc/profile
    source /etc/profile
    第二步:查看
    ls -lth /var/spool/mail/
    第三步:清空
    cat /dev/null > /var/spool/mail/root 这个方法只能清理掉cat  /var/spool/mail/root 命令查看的内容

    echo '' > /var/spool/mail/root  这个方法才能清理掉mail命令查看的内容

    ---------------------
    实战示例:
    # echo "unset MAILCHECK">> /etc/profile
    # source /etc/profile
    # ls -lth /var/spool/mail/
    total 144K
    -rw------- 1 root mail 139K Nov 26 04:08 root
    -rw-rw----. 1 rpc mail 0 Aug 8 2018 rpc
    # cat /dev/null > /var/spool/mail/root
    # cat /var/spool/mail/root
    再查看内容为空了

    ====================
    root邮件转发到自己的邮箱
    方法一:
    修改此文件
    vi /etc/log.d/logwatch.conf
    添加MailTo = root,xxx@xxx.com

    方法二
    vi /etc/aliases
    添加root: xxx@xxx.com

  • 相关阅读:
    PAT (Advanced Level) 1010. Radix (25)
    PAT (Advanced Level) 1009. Product of Polynomials (25)
    PAT (Advanced Level) 1008. Elevator (20)
    PAT (Advanced Level) 1007. Maximum Subsequence Sum (25)
    PAT (Advanced Level) 1006. Sign In and Sign Out (25)
    PAT (Advanced Level) 1005. Spell It Right (20)
    PAT (Advanced Level) 1004. Counting Leaves (30)
    PAT (Advanced Level) 1001. A+B Format (20)
    PAT (Advanced Level) 1002. A+B for Polynomials (25)
    PAT (Advanced Level) 1003. Emergency (25)
  • 原文地址:https://www.cnblogs.com/zdz8207/p/Linux-Centos-mail-root-sendmail.html
Copyright © 2011-2022 走看看