This article mainly explains the "cleaning strategy of journal logs in centos". If you are interested, please come and have a look. The method introduced in this paper is simple, fast and practical. Now let's let the Xiaobian of Western Kunming Cloud take you to learn the "cleaning strategy of journal logs in centos"!
Systemd, which started using CentOS 7, uses journal logs. The management method of this log is different from that of syslog, which can be maintained through management tools.
Use df - h to check the disk file. You can see that there is a log directory/run/log/journal under the/run directory, which takes up several gigabytes of space
Filesystem Size Used Avail Use% Mounted on/dev/mapper/centos-root 8.5G 4.2G 4.4G 49% /tmpfs 16G 1.6G 15G 11% /run
There are many historical logs in the log directory.
Check the amount of disks used by the current journal
journalctl --disk-usage
The cleaning method can be based on the date or the allowable reserved capacity
journalctl --vacuum-time=2djournalctl --vacuum-size=500M
If you want to delete the log file manually, you need to rotate the journal log once before deleting it
systemctl kill --kill-who=main --signal=SIGUSR2 systemd-journald.service
To enable the log limit persistence configuration, you can modify/etc/systemd/journald.conf
SystemMaxUse=16MForwardToSyslog=no
Then restart
systemctl restart systemd-journald.service
Check whether the journal works normally and whether the log file is complete and undamaged
journalctl --verify
At this point, I believe you have a better understanding of the "cleaning strategy of journal logs in Centos". Let's do it in practice! This is the website of Xikun Cloud. More relevant content can be queried in relevant channels. Follow us and continue to learn!