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


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

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

    1. root@ubuntu:perf# top
    2. top - 15:43:17 up 8 min, 1 user, load average: 1.52, 1.68, 0.88
    3. Tasks: 239 total, 2 running, 158 sleeping, 0 stopped, 0 zombie
    4. %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
    5. %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
    6. %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
    7. %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
    8. KiB Mem : 3056276 total, 891360 free, 385072 used, 1779844 buff/cache
    9. KiB Swap: 2097148 total, 2097148 free, 0 used. 2621968 avail Mem
    10. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    11. 2484 root 39 19 227580 129484 79760 R 100.0 4.2 7:11.26 unattended-upgr
    12. 6635 root 20 0 45968 4192 3456 R 0.7 0.1 0:00.15 top
    13. 1 root 20 0 225144 8832 6632 S 0.0 0.3 0:22.25 systemd
    14. 2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd

    使用pidstat也是一样

    1. root@ubuntu:perf# pidstat 1 5
    2. Linux 4.19.66 (ubuntu) 08/17/2022 _x86_64_ (4 CPU)
    3. 03:43:22 PM UID PID %usr %system %guest %wait %CPU CPU Command
    4. 03:43:23 PM 0 10 0.98 0.00 0.00 0.00 0.98 1 rcu_sched
    5. 03:43:23 PM 0 2484 99.02 0.00 0.00 0.00 99.02 3 unattended-upgr
    6. 03:43:23 PM 0 6642 0.98 0.98 0.00 0.00 1.96 0 pidstat
    7. 03:43:23 PM UID PID %usr %system %guest %wait %CPU CPU Command
    8. 03:43:24 PM 0 306 0.00 1.00 0.00 1.00 1.00 0 kworker/u128:28-events_power_efficient
    9. 03:43:24 PM 0 2484 98.00 2.00 0.00 0.00 100.00 3 unattended-upgr
    10. 03:43:24 PM 1000 2615 0.00 1.00 0.00 0.00 1.00 0 sshd
    11. 03:43:24 PM 0 6642 2.00 1.00 0.00 1.00 3.00 0 pidstat
    12. 03:43:24 PM UID PID %usr %system %guest %wait %CPU CPU Command
    13. 03:43:25 PM 0 2484 90.00 10.00 0.00 1.00 100.00 3 unattended-upgr
    14. 03:43:25 PM 1000 2615 0.00 1.00 0.00 0.00 1.00 0 sshd
    15. 03:43:25 PM 0 6642 1.00 0.00 0.00 1.00 1.00 0 pidstat

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

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

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

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

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

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

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

    1. root@ubuntu:perf# top
    2. top - 15:52:01 up 16 min, 1 user, load average: 0.89, 1.25, 1.02
    3. Tasks: 240 total, 1 running, 156 sleeping, 0 stopped, 0 zombie
    4. %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
    5. %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
    6. %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
    7. %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
    8. KiB Mem : 3056276 total, 751244 free, 345656 used, 1959376 buff/cache
    9. KiB Swap: 2097148 total, 2097148 free, 0 used. 2661476 avail Mem

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

  • 相关阅读:
    CRM客户管理系统究竟是什么?如何实施?
    spring cloud rebuild project z
    结构型设计模式之装饰模式:DecoratorPattern
    监控指标--监控指标(3)
    记账工具:轻松添加新账户并记录明细
    上周热点回顾(1.29-2.4)
    Docker容器数据卷
    GNN图神经网络入门
    Jetpack学习之Navigation(1)
    java框架-Spring-扩展原理
  • 原文地址:https://blog.csdn.net/shipinsky/article/details/126397776