Enable Disable the automatic YUM updates

How can I disable YUM automatic update completely?

In some old versioned system, YUM auto-update feature comes as an extension named “yum-autoupdate”, and it contains runlevel scripts and scheduled crontab scripts. 

Enable YUM automatic update

It’s as simple as our services, which can be done as below:

chkconfig --add yum-autoupdate
service yum-autoupdate start

Diable YUM automatic update

Here’s a script for you to do the job, it disables both run-level script, and remove the scheduled cron jobs:

#!/bin/sh
################################
# Disable yum cron and daemons #
################################

echo "++++++++++++++++++++++++++++++++++++++++++++++++"
echo "Yum cron jobs are now disabled"

[ -e /etc/cron.hourly/yum-autoupdate ] && rm -f /etc/cron.hourly/yum-autoupdate
[ -e /etc/cron.hourly/yum ] && rm -f /etc/cron.hourly/yum
[ -e /etc/cron.daily/yum.cron ] && rm -f /etc/cron.daily/yum.cron

yum_status=`chkconfig --list |grep yum |grep "3:on"`
service_name=`chkconfig --list |grep yum | cut -f 1`

for serv in $service_name; do
  if [ "x$yum_status" != "x" ]; then
    echo "++++++++++++++++++++++++++++++++++++++++++++++++"
    echo "+ $serv has been switched to off"
    chkconfig $serv off
  fi

  if [ -e /var/lock/subsys/$serv ]; then
    /etc/init.d/$serv stop
  fi

  echo "Done $serv"
done
############################

If you need to re-enable the service, better to force re-install the extension “yum-autoupdate”, and the removed files will be restored.

[Updates] In recent distributions, the auto-update extension is named yum-updatesd, which has the scheduled cron jobs removed, so basically you can take it as a normal service.

Share Button

Leave a comment

Your email address will not be published. Required fields are marked *