现象

使用Ubuntu发现某个CPU占用率很高

先使用top命令查看,很容易看出进程unattended-upgr占用率很高

top - 06:51:04 up 17 min,  1 user,  load average: 0.96, 0.55, 0.23
Tasks: 102 total,   2 running, 100 sleeping,   0 stopped,   0 zombie
%Cpu0  : 53.2 us, 46.8 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    974.6 total,     76.6 free,    269.1 used,    628.8 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    554.1 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                                                              
   3487 root      20   0  297184 136020  73672 R  99.7  13.6   3:35.90 unattended-upgr                                                                                                                                      

解决

根据网上的文章介绍,修改unattended-upgr的配置

# cat /etc/apt/apt.conf.d/20auto-upgrades 
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

将APT::Periodic::Unattended-Upgrade对应的值修改为0

# cat /etc/apt/apt.conf.d/20auto-upgrades 
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "0";

然后杀死unattended-upgr

pkill unattended-upgr

这时再使用top命令查看系统状态

top - 06:55:45 up 22 min,  1 user,  load average: 0.03, 0.32, 0.23
Tasks: 102 total,   1 running, 101 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.3 us,  0.7 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    974.6 total,    268.3 free,    232.2 used,    474.0 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    595.2 avail Mem 

参考文档