Centos7如何配置自动更新 - 开发说
当前位置: 主页 » Centos » Centos7如何配置自动更新

Centos7如何配置自动更新

      2017年12月17日   阅读 1,580 次     0 评论   Tags: ·

服务器和VPS放置在公网上,每时每刻都可能面临着各种各样的攻击,所以需要及时的更新操作系统的软件,作为一个比较懒的程序猿,肯定要做成自动化,在运维界有一句话“最懒的运维人员,是最牛的运维人员”全部自动化搞定。

 

配置自动化更新操作系统,需要用到的软件crontab和yum-cron。

#安装cronie和yum-cron
yum install -y cronie yum-cron

#关于yum-cron的配置文件
/etc/yum/yum-cron.conf  (每天),
/etc/yum/yum-cron-hourly.conf  (每小时).

#配置自动更新:
vi /etc/yum/yum-cron.conf
#  What kind of update to use:
# default                            = yum upgrade
# security                           = yum --security upgrade
# security-severity:Critical         = yum --sec-severity=Critical upgrade
# minimal                            = yum --bugfix update-minimal
# minimal-security                   = yum --security update-minimal
# minimal-security-severity:Critical =  --sec-severity=Critical update-minimal
update_cmd = default

apply_updates = yes
update_messages = yes
download_updates = yes

//设置你email通知,也可以不设置:
[email]  
email_from = root@localhost
email_to = root
email_host = localhost


#把cronie和yum-cron加入开机启动:
systemctl enable crond yum-cron

#启动crond和yum-cron:
systemctl start crond yum-cron

#配置文件详解:
In any of the two configuration files, configuration is defined through the following directives:

update_cmd = value specifies the category of upgrade where value can take:
default for yum upgrade,
security for yum –security upgrade,
security-severity:Critical for yum –sec-severity=Critical upgrade,
minimal for yum –bugfix upgrade-minimal,
minimal-security for yum –security upgrade-minimal,
minimal-security-severity:Critical for yum –sec-severity=Critical upgrade-minimal.
update_messages = yes/no defines whether a mail is sent when updates from the previously specified category are available.
download_updates = yes/no specifies whether these available updates need to be downloaded.
apply_updates = yes/no defines whether these available updates need to be applied.
random_sleep = 15 specifies the maximum time in minutes to randomly sleep preserving bandwidth and avoiding download storms.
emit_via = stdio/email/none defines what kind of message is used: stdio means written into the /var/log/cron file, email causes a mail to be sent, none doesn’t do anything.
email_from = root@localhost, email_to = root, email_host = localhost defines respectively when the message is a mail the originator’s email address, the recipient’s email address and the host to which the mail is sent.

#参考:
http://linuxaria.com/howto/enabling-automatic-updates-in-centos-7-and-rhel-7

https://www.certdepot.net/rhel7-configure-automatic-updates/

  • 版权声明:本文版权归开发说和原作者所有,未经许可不得转载。文章部分来源于网络仅代表作者看法,如有不同观点,欢迎进行交流。除非注明,文章均由 开发说 整理发布,欢迎转载,转载请带版权。

  • 来源:开发说 ( https://www.kaifashuo.com/ ),提供主机优惠信息深度测评和服务器运维编程技术。
  • 链接:https://www.kaifashuo.com/172.html
  • 评论(0

    1. 还没有任何评论,你来说两句吧

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注