Does yum-cron need to be enabled at boot to download and install updates?

stackedAndOverflowed asked:

Operating system: CentOS 7.6.1810

Question: Does yum-cron need to be enabled at boot to download and install updates?

Background: This is the location and contents of my cron.daily file.



# 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 0

# Action!
exec /usr/sbin/yum-cron

Although I’m not an expert I believe that 0yum-daily.cron runs every day and when it does it instructs yum-cron to execute. Is that all I need?

I ask because 2 different tutorials say to start yum-cron at boot with the enable command.

systemctl enable yum-cron

Maybe I’m missing something but is that necessary? Why would yum-cron need to be enabled when the system boots?

My answer:

Yes, you need to enable and start the yum-cron.service unit.

The cron.daily and cron.hourly entries you see there only run on EL6 and previous versions. They check for the file named /var/lock/subsys/yum-cron and refuse to run if it is absent. But this file is only created by the init system on EL6 and older. It does not exist on EL7 and later. The yum-cron.service unit creates this file when it starts, and deletes the file when it stops, thus enabling or disabling the cron jobs, respectively.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.