■パッケージ管理システムを設定
# yum -y install yum-fastestmirror
… インストールパッケージダウンロード時の最適ミラーサイト(ダウンロードの早いサイト)を自動選択させる
# yum -y update
… インストール済パッケージの一括アップデート
# yum -y install yum-cron
… cronをインストール
# systemctl start yum-cron
… パッケージ自動更新起動
# systemctl enable yum-cron
… パッケージ自動更新自動起動設定
# systemctl is-enabled cron
… 自動起動を確認する
# systemctl list-unit-files -t service | grep cron
… 自動起動を確認する
# systemctl | grep cron
サービスの操作はsystemctlコマンドで行うように変更されている
ただし現時点ではserviceを使うとsystemctlに転送されるため、serviceでも操作できる
(このサーバメモでは、まだserviceとsystemctlが混在している)
サービス操作
# systemctl (start|stop|restart|status ...etc) (サービス名).service
# systemctl start yum-cron.service
… 実例
サービス自動起動設定
# systemctl (enable|disable|is-enabled) (サービス名).service
# systemctl enable yum-cron.service
… 実例
サービスを確認
# systemctl | grep nginx
# systemctl list-unit-files -t service | grep nginx
サービスの状態を確認
# systemctl is-enabled nginx
… 自動起動の設定を確認する
# systemctl list-unit-files
# systemctl list-unit-files -t service
「yum-cron.service」は「yum-cron」のように省略しても問題ないみたい
systemctlでよくつかうオプションまとめ - かべぎわブログ
https://www.kabegiwablog.com/entry/2018/06/13/100000
systemctl コマンド - Qiita
https://qiita.com/sinsengumi/items/24d726ec6c761fc75cc9
【新旧対応】Linuxでの自動起動の設定方法を解説
https://eng-entrance.com/linux_startup
■CentOS6の場合
# yum -y install yum-fastestmirror
# yum -y update
# yum -y install yum-cron
# service yum-cron start
# chkconfig yum-cron on
# chkconfig --list