Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use yum-cron to automatically update the system under Linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use yum-cron automatic update system under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Yum-cron is an automatic update software for RHEL/CentOS system. Keeping the server system up-to-date is a good way to avoid attacks.

First, you need to install the yum-cron package. This package provides the files needed to run yum updates with the cron command. You can install this package if you want to update automatically via cron every night. To install yum cron on CentOS/RHEL 6.x/7.x, enter the following yum command:

$sudo yum install yum-cron

Start the service using systemctl on CentOS/RHEL 7.x:

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

On the CentOS/RHEL 6.x system, run:

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

Yum-cron is an alternative to yum. Makes it very convenient for cron to call yum. The software provides functions such as metadata update, update check, download and installation. The various functions of yum-cron can be configured using configuration files instead of entering a bunch of complex command-line parameters.

Configure yum-cron to update RHEL/CentOS Linux automatically and use editors such as vi to edit the files / etc/yum/yum-cron.conf and / etc/yum/yum-cron-hourly.conf:

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

Ensure that updates are updated automatically when they are available:

Apply_updates = yes

You can set the shipping address of the notification email. Note: localhost will be replaced by the value of system_ name`.

Email_from = root@localhost

Lists the email addresses sent to.

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

The hostname of the email message sent.

Email_host = localhost

If you don't want to update the kernel on CentOS/RHEL 7.x, add the following:

Exclude=kernel*

Disable kernel updates by adding the following under RHEL/CentOS 6.x:

YUM_PARAMETER=kernel*

Save and close the file. Modify the file / etc/yum/yum-cron-hourly.conf if you want to update the system every hour, otherwise the file / etc/yum/yum-cron.conf will run once a day using the following command (check with the cat command):

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

Sample output:

#! / 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# ActionCharacterexec / usr/sbin/yum-cron / etc/yum/yum-cron-hourly.conf [root@centos7-box yum] # cat / EtcAction.DailyUniq0yumSummerdaily.cronActionActionActionexec / usr/sbin/yum-cron / etc/yum/yum-cron-hourly.conf [root@centos7-box yum] # 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# ActionSecretexec / usr/sbin/yum-cron

Complete the configuration. Now your system will be automatically updated once a day.

Thank you for reading this article carefully. I hope the article "how to use yum-cron automatic Update system under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report