OS : Ubuntu 16.04
증상)
인스턴스를 생성하고 apt-get을 통해 패키지 업데이트를 하려는 도중 에러가 발생
.....................................
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
# ps aux |grep apt
root 1152 0.0 0.0 4508 1704 ? Ss 09:56 0:00 /bin/sh /usr/lib/apt/apt.systemd.daily
_apt 1709 4.9 0.2 41996 5660 ? S 09:56 0:01 /usr/lib/apt/methods/http
root 1713 0.0 0.0 12944 1028 pts/0 S+ 09:57 0:00 grep --color=auto apt
원인)
이미 apt-get 를 통해 작업중이면서 lock 이 걸려있는 상태
Ubuntu 16.04에서는 기본으로 systemd timer 를 통해 unattended upgradey (무인업그레이드) 데몬이 제공되어있습니다.
# systemd-analyze
Startup finished in 3.392s (kernel) + 2min 27.703s (userspace) = 2min 31.096s
# systemd-analyze blame
2min 317ms apt-daily.service
21.680s cloud-init.service
3.494s cloud-init-local.service
2.780s cloud-config.service
2.534s dev-vda1.device
1.000s lvm2-monitor.service
878ms apparmor.service
...............................
...............................
관련파일
/lib/systemd/system/apt-daily.service
/lib/systemd/system/apt-daily.timer
# systemctl disable apt-daily.service
# systemctl disable apt-daily.timer
관련된 자료는 아래 링크를 참고