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 RHEL/CentOS Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

How to use yum-cron to automatically update RHEL/CentOS Linux, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

The yum command is a tool used in RHEL / CentOS Linux systems to install and update software packages. I know how to update the system using the yum command line, but I want to update the package automatically with the cron task. How can I configure yum to automatically update system patches or updates using cron?

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.

Install yum cron on CentOS/RHEL 6.x/7.x

Enter the following [yum command] [3]:

$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

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] [4], 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]]; then exit 0fi # ActionSecretexec / usr/sbin/yum-cron / etc/yum/yum-cron-hourly.conf [root@centos7-box yum] # cat / EtcUnip. 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]]; then exit 0fi # ActionSecretexec / usr/sbin/yum-cron

Complete the configuration. Now your system will be automatically updated once a day. Please refer to yum-cron 's instruction manual for more details.

Will man yum-cron be helpful to you after reading the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report