大网数据广告活动
服务器运维问答

Best way to archive journald logs in a space-efficient way?

· 52CE 我爱测

It has been established that journald logs are huge . On this specific system, the logs grow about 3GB per week. For audit purposes I would like to preserve system logs for a longer time than what can I comfortably store on that …

问题原文

原帖链接 · liori · CC BY-SA 4.0

It has been established that journald logs are huge. On this specific system, the logs grow about 3GB per week. For audit purposes I would like to preserve system logs for a longer time than what can I comfortably store on that system; this would only be "just-in-case" storage that doesn't have to be quick to retrieve from. What would be the best way to archive these logs in a space-efficient way?

I am thinking of periodically doing some kind of journalctl | xz >>/var/log/old-logs.txt.xz, but that would be quite wasteful in terms of CPU usage, re-archiving the same parts of data again and again and might miss logs if they get deleted by journalctl, so maybe there's a better way?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

journald rotates its own files, so it's safe to copy the old files (which always have an @ in the filename) elsewhere, compress them, or do whatever you want with them. If it's necessary to look into them, journalctl can be pointed at specific journal files with the --file command line option.

You should also see journald.conf for options to limit journald's disk usage.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-10-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。