禁用 /var/spool/mail 消息

禁用 /var/spool/mail 消息

我有一个 cron 任务,每分钟执行一次 git pull。问题是,当没有更新时,它会在 /var/spool/mail/user 中记录一条消息,提示已更新到最新。

The cron job is * * * * * cd /home/user/dir && git pull

有没有办法可以禁止它在每次执行 git pull 时记录该消息?

完整的日志消息是:

From [email protected]  Tue Aug 28 10:21:04 2018
Return-Path: <[email protected]>
X-Original-To: user
Delivered-To: [email protected]
Received: by localhost.localdomain (Postfix, from userid 1000)
    id 2C1D3207F8E3; Tue, 28 Aug 2018 10:21:04 -0400 (EDT)
From: "(Cron Daemon)" <[email protected]>
To: [email protected]
Subject: Cron <user@localhost> cd /home/user/dir && git pull
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=701>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/1000>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/user>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=user>
X-Cron-Env: <USER=user>
Message-Id: <[email protected]>
Date: Tue, 28 Aug 2018 10:21:04 -0400 (EDT)

Already up-to-date.

答案1

添加 /dev/null 会忽略生成的标准消息。只有在出现错误时才会发送消息。

修改的 cron 作业 * * * * * cd /home/user/dir && git pull > /dev/null

相关内容