配置yum-cron禁止Yum在后台自动下载更新

新安装 CentOS 7 后,Yum自动下载更新默认是开启状态,需要借助yum-cron将其关闭,否则后台会定期产生下行流量。

1. 安装 yum-cron

首先安装yum-cron包:

> yum install -y yum-cron

> yum info yum-cron
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: nrt.edge.kernel.org
 * rpmforge: mirror.fairway.ne.jp
Installed Packages
Name        : yum-cron
Arch        : noarch
Version     : 3.4.3
Release     : 163.el7.centos
Size        : 51 k
Repo        : installed
From repo   : base
Summary     : Files needed to run yum updates as a cron job
URL         : http://yum.baseurl.org/
License     : GPLv2+
Description : These are the files needed to run yum updates as a cron job.
            : Install this package if you want auto yum updates nightly via            : cron.

2. 修改 yum-cron.conf

编辑/etc/yum/yum-cron.conf文件,将update_messagesdownload_updates均修改为no

> vim /etc/yum/yum-cron.conf

......
# Whether a message should be emitted when updates are available,
# were downloaded, or applied.
update_messages = no

# Whether updates should be downloaded when they are available.
download_updates = no
......

3. 重启服务

重启yum-cron服务:

systemctl enable yum-cron
systemctl restart yum-cron

参考文章

  1. 关闭 CentOS yum 的自动更新 - 刀狂剑痴叶小钗 | 博客园
  2. CentOS 7 系统关闭 yum 自动下载更新 | Linux 公社