慢慢欣赏linux 进程unattended-upgr CPU占用率过高定位

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

先使用top命令查看,很容易看出进程unattended-upgr占用率很高,而且基本上都是在nice态

root@ubuntu:perf# top

top - 15:43:17 up 8 min,  1 user,  load average: 1.52, 1.68, 0.88
Tasks: 239 total,   2 running, 158 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  4.0 sy, 96.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.3 si,  0.0 st
%Cpu2  :  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3056276 total,   891360 free,   385072 used,  1779844 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.  2621968 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                       
 2484 root      39  19  227580 129484  79760 R 100.0  4.2   7:11.26 unattended-upgr                               
 6635 root      20   0   45968   4192   3456 R   0.7  0.1   0:00.15 top                                           
    1 root      20   0  225144   8832   6632 S   0.0  0.3   0:22.25 systemd                                       
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.01 kthreadd    

使用pidstat也是一样

root@ubuntu:perf# pidstat 1 5
Linux 4.19.66 (ubuntu)  08/17/2022      _x86_64_        (4 CPU)

03:43:22 PM   UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
03:43:23 PM     0        10    0.98    0.00    0.00    0.00    0.98     1  rcu_sched
03:43:23 PM     0      2484   99.02    0.00    0.00    0.00   99.02     3  unattended-upgr
03:43:23 PM     0      6642    0.98    0.98    0.00    0.00    1.96     0  pidstat

03:43:23 PM   UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
03:43:24 PM     0       306    0.00    1.00    0.00    1.00    1.00     0  kworker/u128:28-events_power_efficient
03:43:24 PM     0      2484   98.00    2.00    0.00    0.00  100.00     3  unattended-upgr
03:43:24 PM  1000      2615    0.00    1.00    0.00    0.00    1.00     0  sshd
03:43:24 PM     0      6642    2.00    1.00    0.00    1.00    3.00     0  pidstat

03:43:24 PM   UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
03:43:25 PM     0      2484   90.00   10.00    0.00    1.00  100.00     3  unattended-upgr
03:43:25 PM  1000      2615    0.00    1.00    0.00    0.00    1.00     0  sshd
03:43:25 PM     0      6642    1.00    0.00    0.00    1.00    1.00     0  pidstat

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

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

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

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

然后杀死unattended-upgr
root@ubuntu:perf# kill -9 2484

使用 pkill unattended-upgr 或者 kill 2484 没有杀死进程

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

root@ubuntu:perf# top

top - 15:52:01 up 16 min,  1 user,  load average: 0.89, 1.25, 1.02
Tasks: 240 total,   1 running, 156 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.3 us,  0.0 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3056276 total,   751244 free,   345656 used,  1959376 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.  2661476 avail Mem 

参考文档
Ubuntu unattended-upgrade 进程长时间占用cpu
https://blog.csdn.net/sinat_31086489/article/details/109384549

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值