요약
한 줄 답: journalctl은 systemd 저널 로그를 조회하는 핵심 도구이며, -u(유닛)와 -b(부팅)로 범위를 자르고 --since/--until과 -p(우선순위)로 시간·심각도를 좁혀 원하는 로그만 빠르게 찾을 수 있습니다.
이 글은 유닛·부팅 단위로 로그를 자르는 방법, 시간 범위와 우선순위로 좁히는 방법, 디스크에 쌓이는 저널을 관리하는 방법을 다룹니다. systemd 서비스의 Type=이나 타이머의 OnCalendar= 설정은 이 글의 범위가 아닙니다.
유닛·부팅 단위로 어떻게 자르나?
한 줄 답: -u로 특정 서비스의 로그만 골라내고, -b로 부팅 세션을 지정하면 둘을 조합해 특정 부팅의 특정 서비스 로그만 볼 수 있습니다.
-u <unit> 옵션은 지정한 유닛(예: nginx.service)의 로그만 필터링합니다.
journalctl -u nginx.service
-b 옵션은 부팅 세션 기준으로 로그를 자릅니다. 인수 없이 쓰면 현재 부팅의 로그를 보여주고, -b -1은 바로 이전 부팅, -b -2는 그 이전 부팅의 로그를 의미합니다.
journalctl -b
journalctl -b -1
두 옵션을 함께 쓰면 특정 부팅 시점의 특정 서비스 로그만 정확히 추출할 수 있습니다.
journalctl -u nginx.service -b
시간 범위·우선순위로 어떻게 좁히나?
한 줄 답: --since/--until로 시간 범위를 지정하고 -p로 우선순위 이상만 걸러내면, 최근에 발생한 심각한 오류만 빠르게 확인할 수 있습니다.
--since와 --until은 "yesterday", "today", "2023-10-01 12:00:00" 같은 형식으로 특정 시간 범위의 로그만 조회합니다.
journalctl --since "today"
journalctl --since "2023-10-01 12:00:00" --until "2023-10-01 18:00:00"
-p <priority>는 syslog 우선순위 레벨(예: err, warning, info)을 지정하며, 해당 레벨 이상의 중요도를 가진 로그만 필터링합니다.
journalctl -p err
시간 범위와 우선순위를 결합하면 검색 대상을 크게 좁힐 수 있습니다.
journalctl -u nginx.service -p err --since "today"
디스크에 남는 저널은 어떻게 관리하나?
한 줄 답: journald.conf의 SystemMaxUse= 등으로 상한선을 정하거나, journalctl --vacuum-time=/--vacuum-size=로 오래된 로그를 수동 정리할 수 있습니다.
systemd-journald 데몬이 수집한 로그는 Storage=persistent 설정 시 디스크에 영구 저장되어 공간을 차지합니다.
/etc/systemd/journald.conf 파일의 SystemMaxUse= 또는 SystemKeepFree= 디렉티브를 통해 전체 저널 크기의 상한선을 설정할 수 있습니다.
# /etc/systemd/journald.conf
[Journal]
SystemMaxUse=500M
즉시 오래된 로그를 정리하고 싶다면 journalctl --vacuum-time= 또는 --vacuum-size= 명령을 사용합니다.
journalctl --vacuum-time=1M
journalctl --vacuum-size=1G
자주 묻는 질문은 무엇입니까?
| 질문 | 답 |
|---|---|
| 실시간으로 로그를 보려면 어떻게 합니까? | journalctl -f(follow) 옵션을 사용합니다. 특정 유닛(-u)과 함께 쓰면 더 유용합니다. |
| 여러 부팅을 한꺼번에 보려면 어떻게 합니까? | -b에 원하는 숫자를 지정해 부팅별로 나눠 확인합니다. |
| 디스크 공간이 급하게 부족하면 어떻게 합니까? | journalctl --vacuum-size=로 즉시 크기를 줄일 수 있습니다. |
정리하면 어떻게 됩니까?
journalctl의 -u/-b/--since/-p 필터를 조합하면 방대한 시스템 로그 속에서도 필요한 서비스 로그를 신속하게 찾아낼 수 있습니다. 여기에 journald.conf의 용량 설정과 --vacuum-* 명령을 더하면 디스크 공간도 효율적으로 유지할 수 있습니다.
Summary
Short answer: journalctl is the core tool for querying the systemd journal. Use -u (unit) and -b (boot) to narrow the scope, then --since/--until and -p (priority) to filter by time and severity so you can find exactly the logs you need.
This post covers slicing logs by unit and boot, narrowing them by time range and priority, and managing the disk space journals consume. It does not cover a service's Type= setting or a timer's OnCalendar= configuration.
How do you slice logs by unit and boot?
Short answer: Use -u to filter a specific service's logs, and -b to select a boot session; combine both to see one service's logs from one specific boot.
The -u <unit> option filters logs for a specific unit, such as nginx.service.
journalctl -u nginx.service
The -b option slices logs by boot session. Used with no argument it shows the current boot's logs; -b -1 is the previous boot, and -b -2 is the boot before that.
journalctl -b
journalctl -b -1
Combining both options extracts exactly one service's logs from one specific boot.
journalctl -u nginx.service -b
How do you narrow logs by time range and priority?
Short answer: Set a window with --since/--until and filter by severity with -p to quickly surface recent critical errors.
--since and --until accept formats like "yesterday", "today", or "2023-10-01 12:00:00" to query logs within a specific time range.
journalctl --since "today"
journalctl --since "2023-10-01 12:00:00" --until "2023-10-01 18:00:00"
-p <priority> specifies a syslog priority level (such as err, warning, or info) and filters for logs at that level or higher.
journalctl -p err
Combining a time range with a priority filter narrows the search considerably.
journalctl -u nginx.service -p err --since "today"
How do you manage the disk space journals consume?
Short answer: Set a cap with SystemMaxUse= in journald.conf, or clean up old logs manually with journalctl --vacuum-time=/--vacuum-size=.
Logs collected by the systemd-journald daemon consume disk space once persistent storage (Storage=persistent) is configured.
The SystemMaxUse= or SystemKeepFree= directives in /etc/systemd/journald.conf set an upper bound on total journal size.
# /etc/systemd/journald.conf
[Journal]
SystemMaxUse=500M
To clean up old logs immediately, use the journalctl --vacuum-time= or --vacuum-size= commands.
journalctl --vacuum-time=1M
journalctl --vacuum-size=1G
What are some common questions?
| Question | Answer |
|---|---|
| How do I follow logs in real time? | Use the journalctl -f (follow) option, which is especially useful when combined with a specific unit (-u). |
| How do I check several boots at once? | Pass different numbers to -b and check each boot separately. |
| What if disk space runs low urgently? | Use journalctl --vacuum-size= to shrink the journal immediately. |
What is the main takeaway?
Combining journalctl's -u/-b/--since/-p filters lets you quickly find the exact service logs you need within a vast system log. Adding journald.conf's size settings and the --vacuum-* commands keeps disk usage under control as well.
'임베디드' 카테고리의 다른 글
| aarch64 크로스 컴파일 CMake, toolchain 파일은 어떻게 쓰나 (0) | 2026.09.22 |
|---|---|
| Linux perf, 핫스팟을 프로파일하는 법 (1) | 2026.09.19 |
| libgpiod, 리눅스에서 GPIO 라인을 다루는 법 (0) | 2026.09.18 |
| Kconfig, 커널 옵션을 메뉴에서 고르는 법 (0) | 2026.09.16 |
| UUU 명령 하나로 eMMC 파형과 드라이버 코드까지 연결해 보기 (0) | 2026.09.14 |
