如何停止 systemd-journal 使用 100% CPU 资源 Ubuntu 20.04 LTS Focal Fossa) 并每分钟自动创建 360 MB 的日志文件

如何停止 systemd-journal 使用 100% CPU 资源 Ubuntu 20.04 LTS Focal Fossa) 并每分钟自动创建 360 MB 的日志文件

在我的 Ubuntu 20 桌面系统中,每分钟都会生成 360 MB 的日志数据,并且我的处理器正忙于 100% 的利用率运行systemd-journal

/var/log/journal/42b76941196c44ebabf29f6efc5047c7/每分钟它在文件夹中存储 128Mb * 3 个文件

我正在使用此命令手动清除日志。

sudo journalctl --vacuum-size=50M
Deleted archived journal /var/log/journal/42b76941196c44ebabf29f6efc5047c7/system@00000000000000000000000000000000-00000000015de62d-0005a8bd92211c3a.journal (128.0M).
Deleted archived journal /var/log/journal/42b76941196c44ebabf29f6efc5047c7/system@00000000000000000000000000000000-000000000160c6b7-0005a8bd93351c1b.journal (128.0M).
Deleted archived journal /var/log/journal/42b76941196c44ebabf29f6efc5047c7/system@00000000000000000000000000000000-000000000163a7b1-0005a8bd945c0bf2.journal (128.0M).
Vacuuming done, freed 3.8G of archived journals from /var/log/journal/42b76941196c44ebabf29f6efc5047c7.
Vacuuming done, freed 0B of archived journals from /run/log/journal.

几分钟内就创建了 3.8 GB 的数据,日志文件不断创建,我的 CPU 一直处于 100% 繁忙状态

目前我已经完成了这个设置的改变:

使用sudo nano /etc/systemd/journald.conf,我修改了这个设置

SystemMaxUse=50M
Software=none           -- After adding this line it stopped creating files but systemd-journal process is eating 100% of cup
MaxLevelStore=err
MaxLevelSyslog=warning
MaxLevelKMsg=warning
MaxLevelConsole=err
> top
PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                             >
328 root      19  -1  468040 265696 263872 R 100.0   1.6  31:13.14 systemd-journal
/var/log/journal/42b76941196c44ebabf29f6efc5047c7  ls -lhsa
total 3.5G
 12K drwxr-sr-x+ 2 root systemd-journal  12K Jun 23 11:01 .
4.0K drwxr-sr-x+ 3 root systemd-journal 4.0K Jun 15 02:45 ..
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:53 system@00000000000000000000000000000000-0000000000b928b7-0005a8bd50cff991.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:53 system@00000000000000000000000000000000-0000000000bc0a5c-0005a8bd51dfebc1.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:53 system@00000000000000000000000000000000-0000000000beeae8-0005a8bd5327bbb9.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:54 system@00000000000000000000000000000000-0000000000c1cf12-0005a8bd5491ec30.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:54 system@00000000000000000000000000000000-0000000000c4b0ab-0005a8bd55a40899.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:54 system@00000000000000000000000000000000-0000000000c7947b-0005a8bd56bf31e1.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:54 system@00000000000000000000000000000000-0000000000ca7b31-0005a8bd57e08298.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:55 system@00000000000000000000000000000000-0000000000cd5d82-0005a8bd58f27c6f.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:55 system@00000000000000000000000000000000-0000000000d0421e-0005a8bd5a0eb633.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:55 system@00000000000000000000000000000000-0000000000d324e0-0005a8bd5b414cea.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:56 system@00000000000000000000000000000000-0000000000d60651-0005a8bd5c5b194e.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:56 system@00000000000000000000000000000000-0000000000d8eb81-0005a8bd5d7f5e1d.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:56 system@00000000000000000000000000000000-0000000000dbd098-0005a8bd5e9a9369.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:57 system@00000000000000000000000000000000-0000000000deb64b-0005a8bd5fbe668e.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:57 system@00000000000000000000000000000000-0000000000e19c03-0005a8bd60d8c9fe.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:57 system@00000000000000000000000000000000-0000000000e4814d-0005a8bd61ee85f3.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:58 system@00000000000000000000000000000000-0000000000e766ad-0005a8bd63092fa2.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:58 system@00000000000000000000000000000000-0000000000ea47e6-0005a8bd6420b7d5.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:58 system@00000000000000000000000000000000-0000000000ed2b78-0005a8bd6592ecbf.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:59 system@00000000000000000000000000000000-0000000000f011ae-0005a8bd66fd52a8.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:59 system@00000000000000000000000000000000-0000000000f2f60c-0005a8bd68164432.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 10:59 system@00000000000000000000000000000000-0000000000f5d72f-0005a8bd69297455.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 11:00 system@00000000000000000000000000000000-0000000000f8bb3a-0005a8bd6a453704.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 11:00 system@00000000000000000000000000000000-0000000000fb9c70-0005a8bd6b770daa.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 11:00 system@00000000000000000000000000000000-0000000000fe8190-0005a8bd6c92d47f.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 11:01 system@00000000000000000000000000000000-00000000010166e5-0005a8bd6dac401f.journal
129M -rw-r-----+ 1 root systemd-journal 128M Jun 23 11:01 system@00000000000000000000000000000000-0000000001044c9e-0005a8bd6ecfe4c3.journal
 24M -rw-r-----+ 1 root systemd-journal  24M Jun 23 11:01 system.journal
8.0M -rw-r-----+ 1 root systemd-journal 8.0M Jun 23 11:01 user-1000.journal

系统详细信息:

$ cat /etc/os-release

NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

我如何停止 systemd-journal 以使其不占用 100% 的 CPU 资源?

答案1

以下是我查看日志后执行的几个步骤。

在我的 /var/log 文件夹中,这两个文件也各自占用了 71 GB 的空间。

cd /var/log

ls -lsha

71G -rw-r-----   1 syslog            adm              71G Jun 24 15:51 kern.log
71G -rw-r-----   1 syslog            adm              71G Jun 24 15:52 syslog

是否对此文件进行了拖尾

sudo tail -n 10 /var/log/syslog

Jun 24 15:52:17 crusader update-notifier.desktop[3393]: Cannot stat file /proc/3137/fd/10: Permission denied
Jun 24 15:52:17 crusader update-notifier.desktop[3393]: Cannot stat file /proc/3137/fd/11: Permission denied
Jun 24 15:52:17 crusader update-notifier.desktop[3393]: Cannot stat file /proc/3137/fd/16: Permission denied
Jun 24 15:52:17 crusader update-notifier.desktop[3393]: Cannot stat file /proc/3137/fd/17: Permission denied
Jun 24 15:52:48 crusader gnome-shell[1903]: Some code accessed the property 'discreteGpuAvailable' on the module 'appDisplay'. That property was defined with 'let' or 'const' inside the module. This was previously supported, but is not correct according to the ES6 standard. Any symbols to be exported from a module must be defined with 'var'. The property access will work as previously for the time being, but please fix your code anyway.
Jun 24 15:52:48 crusader gnome-shell[1903]: ../clutter/clutter/clutter-actor.c:10556: The clutter_actor_set_allocation() function can only be called from within the implementation of the ClutterActor::allocate() virtual function.
sudo tail -n 10 /var/log/kern.log

ieport 0000:00:1c.5: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID) Jun 2 pcieport 0000:00:1c.5: AER: device [8086:9d15] error status/mask=00000001/00002000 kernel: [ 178.057760] pcieport 0000:00:1c.5: AER: [ 0] RxErr

我打开了 grub 文件并修改了此行..


sudo nano /etc/default/grub

#GRUB_CMDLINE_LINUX_DEFAULT='quiet splash'

with this below line

GRUB_CMDLINE_LINUX_DEFAULT='quiet splash pci=noaer'

ctrl o 输入 ctrl x 重启

重新启动我的系统,当我运行 top 命令时,我的 CPU 利用率回到之前的状态。也就是说,systemd-journal 进程没有运行,也没有占用我 CPU 的 100%。

截至目前系统运行良好。

在运行上述命令之前,我也运行了一些命令。

sudo apt-get update
sudo apt-get dist-upgrade

相关内容