yumを自動で更新チェックする、自動で更新する

yumの自動更新をするには、標準パッケージのyum-updatesdと拡張パッケージのyum-cronがあります。

yum-updatesd
yum-cron

yum-updatesdyum-cron
パッケージbaseextras
起動常駐cron
更新通知内容パッケージ名のみパッケージ名とバージョン
自動アップデート可能可能

yum-updatesd

インストール

標準でインストールされています。
インストールされているかを確認するのは次のコマンド。

rpm -q yum-updatesd

インストールするのは次のコマンド。

yum install yum-updatesd

設定

設定ファイルは /etc/yum/yum-updatesd.conf です。

[main]
# how often to check for new updates (in seconds)
run_interval = 3600
# how often to allow checking on request (in seconds)
updaterefresh = 600

# how to send notifications (valid: dbus, email, syslog)
emit_via = dbus
# should we listen via dbus to give out update information/check for
# new updates
dbus_listener = yes

# automatically install updates
do_update = no
# automatically download updates
do_download = no
# automatically download deps of updates
do_download_deps = no

更新のチェック間隔(秒)は1時間おきになっています。

run_interval = 3600

通知方法はD-busになっています。

emit_via = dbus

自動ではアップデートしないようになっています。自動でアップデートするにはyesにします。

do_update = no

自動ではダウンロードしないようになっています。自動でダウンロードするにはyesにします。

do_download = no

自動では依存関係のあるパッケージをダウンロードしないようになっています。自動でダウンロードするにはyesにします。

do_download_deps = no

メールで通知する設定

# 通知方法をメールにする
emit_via = email
# メールの送信先
emit_to = root@example.com
# メールの送信者のアドレス
emit_from = yumupdatesd@example.com
# SMTP サーバ
smtp_server=localhost:25

更新チェックの間隔が1時間になっているので1時間ごとにメールが飛んできます。時間を変更するのは run_interval です。

実際に飛んでくるメール内容

Hi,
This is the automatic update system on mail.localdomain.

There are 5 package updates available. Please run the system updater.

Packages available for update:

    kpartx
    dmidecode
    nspr
    wget
    selinux-policy-targeted

Thank You,
Your Computer

yum-updatesd の起動

service yum-updatesd restart

OS起動時の自動起動

chkconfig yum-updatesd on

確認

chkconfig --list yum-updatesd

yum-cron

インストール

yum install yum-cron

/etc/cron.daily/yum.cron がインストールされます。

設定

設定ファイルは /etc/sysconfig/yum-cron です。

自動でアップデートするようになっています。自動でアップデートしないようにするにはyesにします。

# Don’t install, just check (valid: yes|no)
CHECK_ONLY=no

自動でダウンロードするようになっています。自動でダウンロードしないようにするにはnoにします。

# Don’t install, just check and download (valid: yes|no)
# Implies CHECK_ONLY=yes (gotta check first to see what to download)
DOWNLOAD_ONLY=yes

Update通知のメール送信先はMAILTOで指定します。

# メールの通知先
MAILTO=root@example.com

[参考記事] cronのメール送信先を指定する方法
[参考記事] cron実行時の標準出力のメールを飛ばさない方法
[参考記事] cron実行時のPATHなどの環境変数を確認する方法

起動

/etc/init.d/yum-cron start

再起動

/etc/init.d/yum-cron restart

停止

/etc/init.d/yum-cron stop

yum-updatesdが起動している場合には、停止して自動起動もオフにします。

/etc/init.d/yum-updatesd stop
chkconfig yum-updatesd off

OS起動時の自動起動

chkconfig yum-cron on

確認

chkconfig --list yum-cron

更新の通知

rootにsyslogメールが届きます。

/etc/cron.daily/yum.cron:

New updates available for host s1.example.com

autofs.i386 1:5.0.1-31 updates
…………
……

関連記事

スポンサーリンク

head要素と子孫要素のdisplayプロパティを変更できない

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る