0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

E: Could not get lock /var/lib/apt/lists/lock

0
Posted at

Ubuntu 24.04 LTS にログインすると以下のようなメッセージが出ていた。

1 updates could not be installed automatically. For more details,
see /var/log/unattended-upgrades/unattended-upgrades.log
*** システムの再起動が必要です ***

それを無視して apt しようとしたら

#  apt update
パッケージリストを読み込んでいます... 完了
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1218121 (apt-get)
N: Be aware that removing the lock file is not a solution and may break your system.
E: ディレクトリ /var/lib/apt/lists/ をロックできません

バックグラウンドの Update タスクかな?

$ ps -auxww | grep 1218121
root     1218121  0.0  0.1  16960 11536 ?        S     9月10   8:53 apt-get -qq -y update
nanbuwks 3900454  0.0  0.0   4732  2512 pts/0    S+   13:42   0:00 grep --color=auto 1218121

ありゃ、1ヶ月以上前のプロセスですね。
ログを見てみます。




.
.
.
Start-Date: 2026-09-04  06:04:58
Commandline: /usr/bin/unattended-upgrade
Upgrade: libgcrypt20:amd64 (1.10.3-2ubuntu0.1, 1.10.3-2ubuntu0.2)
End-Date: 2026-09-04  06:05:00

Start-Date: 2026-09-04  06:05:02
Commandline: /usr/bin/unattended-upgrade
Upgrade: libevent-2.1-7t64:amd64 (2.1.12-stable-9ubuntu2, 2.1.12-stable-9ubuntu2.1)
End-Date: 2026-09-04  06:05:03

Start-Date: 2026-09-04  06:05:05
Commandline: /usr/bin/unattended-upgrade
Upgrade: libtinfo6:amd64 (6.4+20240113-1ubuntu2.1, 6.4+20240113-1ubuntu2.2), ncurses-base:amd64 (6.4+20240113-1ubuntu2.1, 6.4+20240113-1ubuntu2.2), libncursesw6:amd64 (6.4+20240113-1ubuntu2.1, 6.4+20240113-1ubuntu2.2), ncurses-bin:amd64 (6.4+20240113-1ubuntu2.1, 6.4+20240113-1ubuntu2.2), ncurses-term:amd64 (6.4+20240113-1ubuntu2.1, 6.4+20240113-1ubuntu2.2), libncurses6:amd64 (6.4+20240113-1ubuntu2.1, 6.4+20240113-1ubuntu2.2)
End-Date: 2026-09-04  06:05:14

Start-Date: 2026-09-06  06:48:13
Commandline: /usr/bin/unattended-upgrade
Install: linux-hwe-7.0-tools-7.0.0-31:amd64 (7.0.0-31.31~24.04.1, automatic), linux-image-7.0.0-31-generic:amd64 (7.0.0-31.31~24.04.1, automatic), linux-headers-7.0.0-31-generic:amd64 (7.0.0-31.31~24.04.1, automatic), linux-modules-7.0.0-31-generic:amd64 (7.0.0-31.31~24.04.1, automatic), linux-hwe-7.0-headers-7.0.0-31:amd64 (7.0.0-31.31~24.04.1, automatic), linux-tools-7.0.0-31-generic:amd64 (7.0.0-31.31~24.04.1, automatic)
Upgrade: linux-headers-generic-hwe-24.04:amd64 (7.0.0-30.30~24.04.1, 7.0.0-31.31~24.04.1), linux-generic-hwe-24.04:amd64 (7.0.0-30.30~24.04.1, 7.0.0-31.31~24.04.1), linux-image-generic-hwe-24.04:amd64 (7.0.0-30.30~24.04.1, 7.0.0-31.31~24.04.1)
End-Date: 2026-09-06  06:48:44

Start-Date: 2026-09-06  06:48:47
Commandline: /usr/bin/unattended-upgrade
Upgrade: linux-tools-common:amd64 (6.8.0-138.138, 6.8.0-139.139), linux-libc-dev:amd64 (6.8.0-138.138, 6.8.0-139.139)
End-Date: 2026-09-06  06:48:53

Start-Date: 2026-09-06  06:48:55
Commandline: /usr/bin/unattended-upgrade
Remove: linux-image-7.0.0-30-generic:amd64 (7.0.0-30.30~24.04.1)
End-Date: 2026-09-06  06:48:59

Start-Date: 2026-09-06  06:49:01
Commandline: /usr/bin/unattended-upgrade
Remove: linux-headers-7.0.0-30-generic:amd64 (7.0.0-30.30~24.04.1)
End-Date: 2026-09-06  06:49:02

Start-Date: 2026-09-06  06:49:04
Commandline: /usr/bin/unattended-upgrade
Remove: linux-tools-7.0.0-30-generic:amd64 (7.0.0-30.30~24.04.1)
End-Date: 2026-09-06  06:49:05

Start-Date: 2026-09-06  06:49:07
Commandline: /usr/bin/unattended-upgrade
Remove: linux-hwe-7.0-headers-7.0.0-30:amd64 (7.0.0-30.30~24.04.1)
End-Date: 2026-09-06  06:49:09

Start-Date: 2026-09-06  06:49:10
Commandline: /usr/bin/unattended-upgrade
Remove: linux-modules-7.0.0-30-generic:amd64 (7.0.0-30.30~24.04.1)
End-Date: 2026-09-06  06:49:12

Start-Date: 2026-09-06  06:49:13
Commandline: /usr/bin/unattended-upgrade
Remove: linux-hwe-7.0-tools-7.0.0-30:amd64 (7.0.0-30.30~24.04.1)
End-Date: 2026-09-06  06:49:14

ログはここで止まっていました。再起動やむなしですね。自動更新は難しいところです。

再起動すると apt コマンドはもうまく動くようになりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?