Linux下如何使用yum-cron自动更新系统

发布时间:2022-01-29 19:24:01 作者:小新
来源:亿速云 阅读:288

这篇文章主要介绍了Linux下如何使用yum-cron自动更新系统,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

yum-cron是一个RHEL/CentOS系统自动更新的软件。保持服务器系统实时更新是一个很好避免攻击的办法。

Linux下如何使用yum-cron自动更新系统

首先需要安装 yum-cron 软件包。该软件包提供以 cron 命令运行 yum 更新所需的文件。如果你想要每晚通过 cron 自动更新可以安装这个软件包。 CentOS/RHEL 6.x/7.x 上安装 yum cron 输入以下 yum 命令:

$ sudo yum install yum-cron

使用 CentOS/RHEL 7.x 上的 systemctl 启动服务:

$ sudo systemctl enable yum-cron.service
$ sudo systemctl start yum-cron.service
$ sudo systemctl status yum-cron.service

在 CentOS/RHEL 6.x 系统中,运行:

$ sudo chkconfig yum-cron on
$ sudo service yum-cron start

yum-cron 是 yum 的一个替代方式。使得 cron 调用 yum 变得非常方便。该软件提供了元数据更新、更新检查、下载和安装等功能。yum-cron 的各种功能可以使用配置文件配置,而不是输入一堆复杂的命令行参数。

配置 yum-cron 自动更新 RHEL/CentOS Linux 使用 vi 等编辑器编辑文件 /etc/yum/yum-cron.conf 和 /etc/yum/yum-cron-hourly.conf:

$ sudo vi /etc/yum/yum-cron.conf

确保更新可用时自动更新:

apply_updates = yes

可以设置通知 email 的发件地址。注意: localhost将会被system_name` 的值代替。

email_from = root@localhost

列出发送到的 email 地址。

email_to = your-it-support@some-domain-name

发送 email 信息的主机名。

email_host = localhost

CentOS/RHEL 7.x 上不想更新内核的话,添加以下内容:

exclude=kernel*

RHEL/CentOS 6.x 下添加以下内容来禁用内核更新:

YUM_PARAMETER=kernel*

保存并关闭文件。如果想每小时更新系统的话修改文件 /etc/yum/yum-cron-hourly.conf,否则文件 /etc/yum/yum-cron.conf 将使用以下命令每天运行一次(使用 cat 命令 查看):

$ cat /etc/cron.daily/0yum-daily.cron

示例输出:

#!/bin/bash# Only run if this flag is set. The flag is created by the yum-cron init# script when the service is started -- this allows one to use chkconfig and# the standard "service stop|start" commands to enable or disable yum-cron.if [[ ! -f /var/lock/subsys/yum-cron ]]; thenexit 0fi# Action!exec /usr/sbin/yum-cron /etc/yum/yum-cron-hourly.conf
[root@centos7-box yum]# cat /etc/cron.daily/0yum-daily.cron#!/bin/bash# Only run if this flag is set. The flag is created by the yum-cron init# script when the service is started -- this allows one to use chkconfig and# the standard "service stop|start" commands to enable or disable yum-cron.if [[ ! -f /var/lock/subsys/yum-cron ]]; thenexit 0fi# Action!exec /usr/sbin/yum-cron

完成配置。现在你的系统将每天自动更新一次。


感谢你能够认真阅读完这篇文章,希望小编分享的“Linux下如何使用yum-cron自动更新系统”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

推荐阅读:
  1. linux下SVN配置如何实现项目目录自动更新
  2. Linux 下如何使用NMON分析系统性能

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux yum-cron

上一篇:Linux下如何使用DNSmasq建本地DNS服务器

下一篇:Linux系统umount命令怎么用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》