Ubuntu 18.04 ã§ OS èµ·åæã® apt update 㨠unattended-upgrade ãæå¶ããæ¹æ³
æéã®ãªã人åãã®ã¾ã¨ã
sudo systemctl edit apt-daily.timer sudo systemctl edit apt-daily-upgrade.timer
ã©ã¡ããæ¬¡ã®å 容ã§ä¿åãã¾ãã
[Timer] Persistent=false
ãããã¯ãç´æ¥ãã¡ã¤ã«ãç·¨éãã¦åæ ãã¦ãããã§ãã
sudo install -d -o root -g root -m 755 /etc/systemd/system/apt-daily.timer.d cat <<EOF | sudo tee /etc/systemd/system/apt-daily.timer.d/override.conf [Timer] Persistent=false EOF cp -pR /etc/systemd/system/apt-daily.timer.d/ /etc/systemd/system/apt-daily-upgrade.timer.d/ sudo systemctl daemon-reload
ä½ãåé¡ãªã®ãï¼
Ubuntu 18.04ãå°ãªãã¨ã EC2 ç¨ã® Ubuntu cloud image ã® 20200131 ç (18.04.4) ã§ã¯ãæ¯æ¥ 6:00 é ã« apt update 㨠unattended-upgrade (ã»ãã¥ãªãã£é¢é£ã®æ´æ°ããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«) ãè¡ããã (詳ããã¯å¾è¿°) ã®ã§ããããã®æé帯ã«é»æºããªãã§ç¨¼åãã¦ããªãã£ãå ´åã¯ã次㮠OS èµ·åæã«å®è¡ãããè¨å®ã«ãªã£ã¦ãã¾ãã
ããã®æé帯ã«é»æºããªãã§ç¨¼åãã¦ããªãã£ããã¯ãAMI ããã¤ã³ã¹ã¿ã³ã¹ãèµ·åããã¨ããåãç¶æ³ã«ãªãã®ã§ãAMI ãå¤ããã°å¤ãã»ã©æ´æ°ããã±ã¼ã¸ãå¤ããªããèµ·åç´å¾ã«è² è·ãé«ã¾ã£ããããã°ãã apt install ã§ããªã (unattended-upgrade ãããã¯ãç²å¾ãã¦ããã®ã§) æéãç¶ããããã¾ãã
ãã®çµæã次ã®ãããªåé¡ãçºçãã¾ãã
- ã¤ã³ã¹ã¿ã³ã¹èµ·åå¾ã«èªåçã«ãããã¸ã§ãã³ã°ãè¡ãããã«ãã¦ããéç¨ã®å ´åããããã¸ã§ãã³ã° (ã®éç¨ã®ããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«) ãå®éããã¾ã§ã®æéãå®å®ããªãã£ãããå ´åã«ãã£ã¦ã¯ã¿ã¤ã ã¢ã¦ããã¦ã¨ã©ã¼çµäºãã¦ãã¾ã
ç¹ã«ãªã¼ãã¹ã±ã¼ãªã³ã°ã®å ´åã¯ãä¸å»ãæ©ãã¤ã³ã¹ã¿ã³ã¹ãæå ¥ãããã®ã§æ·±å»ãªåé¡ã«ãªãã¾ãã
ã¾ããããAMI æ¡åç¨ã®ã¤ã³ã¹ã¿ã³ã¹ããæ¥æ¬¡ã§ AMI ãä½ãéç¨ã®å ´åã¯ãããã±ã¼ã¸ã¯ã»ã¼ææ°ã§ãããã¨ãæå¾ ã§ãã¾ãã
ã¨ããããã§ã OS èµ·åæã®æ´æ°å¦çãå®è¡ãããªãããã«ãããã¨ããã話ã§ããã
æéã®ãã人åãã®è©³ç´°
ã¾ã宿çã«æ´æ°å¦çã宿½ãããä»çµã¿ã®èª¬æããã
次㮠2 ã¤ã® systemd ã® timer ã¦ããããããªã¬ã¼ã¨ãªãã¾ãã
apt-daily.timerapt-daily-upgrade.timer
å 容ã確èªããã¨ã
$ systemctl cat apt-daily.timer # /lib/systemd/system/apt-daily.timer [Unit] Description=Daily apt download activities [Timer] OnCalendar=*-*-* 6,18:00 RandomizedDelaySec=12h Persistent=true [Install] WantedBy=timers.target $ systemctl cat apt-daily-upgrade.timer # /lib/systemd/system/apt-daily-upgrade.timer [Unit] Description=Daily apt upgrade and clean activities After=apt-daily.timer [Timer] OnCalendar=*-*-* 6:00 RandomizedDelaySec=60m Persistent=true [Install] WantedBy=timers.target
ã¨ãªã£ã¦ããã apt-daily.timer ã¯æ¯æ¥ 6:00 㨠18:00 é ã apt-daily-upgrade.timer ã¯æ¯æ¥ 6:00 é ã«çºç«ããã®ããããã¾ãã
çºç«ããã¨ã対å¿ãã systemd ã® service ã¦ããããå®è¡ããã¾ãã
systemctl cat ã§ç¢ºèªããã¨ãå®è¡ãããã³ãã³ãã©ã¤ã³ (ExecStart) ã確èªã§ãã¾ãã
apt-daily.serviceExecStart=/usr/lib/apt/apt.systemd.daily update
apt-daily-upgrade.serviceExecStart=/usr/lib/apt/apt.systemd.daily install
ãã£ããè¨ãã¨ã
/usr/lib/apt/apt.systemd.daily update ã¯
- apt-get update
- apt-get --download-only dist-upgrade
- unattended-upgrade --download-only
/usr/lib/apt/apt.systemd.daily install ã¯
- unattended-upgrade
ãè¡ãããã®ãã®ã§ãAPT ã®è¨å®ã§åå¥ã«å®æ½ãã/ããªããå¶å¾¡ãããã¨ãã§ãã¾ãã
ããã©ã«ãã§ã®æ¬¡ã®ãããªè¨å®ã«ãªã£ã¦ãã¦ã
$ apt-config dump | grep Periodic APT::Periodic ""; APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "0"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "1";
apt-get update宿½ãã--download-onlyç³»ã¯å®æ½ããªãunattended-upgrade宿½ãã
ã¨ããæåã«ãªãã¾ãã
ããã¾ã§ã宿çã«å®è¡ãããä»çµã¿ã®èª¬æã§ã次ããã¯ä¸»é¡ã® OS èµ·åæã®æ´æ°å¦çã®ä»çµã¿ã«ã¤ãã¦ã§ãã
timer ã¦ãããã®å®ç¾©ãã¿ã㨠Persistent=true ã¨ããã®ããããããããã¢ã§ãã
systemd.timer(5) ããå¼ç¨ããã¨
Persistent=
Takes a boolean argument. If true, the time when the service unit was last triggered is stored on disk. When the timer is activated, the service unit is triggered immediately if it would have been triggered at least once during the time when the timer was inactive. This is useful to catch up on missed runs of the service when the system was powered down. Note that this setting only has an effect on timers configured with OnCalendar=. Defaults to false.
ã¨ã®ãã¨ãªã®ã§ãåé ã®æ¹æ³ã§ Persistent=false ã¨ä¸æ¸ãè¨å®ããããã§ãã
ã¡ãªã¿ã«
宿çãªã®ãå«ãä¸åã®èªåçãªæ´æ°å¦çããªãã«ãããå ´åã¯ã /usr/lib/apt/apt.systemd.daily ã«
# check if the user really wants to do something AutoAptEnable=1 # default is yes eval $(apt-config shell AutoAptEnable APT::Periodic::Enable) if [ $AutoAptEnable -eq 0 ]; then exit 0 fi
ã¨ããå¦çãããã®ã§
echo 'APT::Periodic::Enable "0";' | sudo tee /etc/apt/apt.conf.d/99disable-periodic
ã¨ãããã¨ããããããªããã¨æãã¾ãã
ã㨠/etc/cron.daily/apt-compat ã¨ãã crontab ããããã§ããã
if [ -d /run/systemd/system ]; then exit 0 fi
ã¨ãªã£ã¦ãã®ã§ systemd ãªç°å¢ã§ã¯ç¡ãã®ã¨åãã§ãã