1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2012 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="journalctl">
27 <title>journalctl</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>journalctl</refentrytitle>
42 <manvolnum>1</manvolnum>
46 <refname>journalctl</refname>
47 <refpurpose>Query the systemd journal</refpurpose>
52 <command>journalctl <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">MATCHES</arg></command>
57 <title>Description</title>
59 <para><command>journalctl</command> may be used to
60 query the contents of the
61 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
63 <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
65 <para>If called without parameter will show the full
66 contents of the journal, starting with the oldest
67 entry collected.</para>
69 <para>If one or more match arguments are passed the
70 output is filtered accordingly. A match is in the
71 format <literal>FIELD=VALUE</literal>,
72 e.g. <literal>_SYSTEMD_UNIT=httpd.service</literal>,
73 referring to the components of a structured journal
75 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
76 for a list of well-known fields. If multiple matches
77 are specified matching different fields the log
78 entries are filtered by both, i.e. the resulting output
79 will show only entries matching all the specified
80 matches of this kind. If two matches apply to the same
81 field, then they are automatically matched as
82 alternatives, i.e. the resulting output will show
83 entries matching any of the specified matches for the
84 same field. Finally, if the character
85 "<literal>+</literal>" appears as separate word on the
86 command line all matches before and after are combined
87 in a disjunction (i.e. logical OR).</para>
89 <para>Output is interleaved from all accessible
90 journal files, whether they are rotated or currently
91 being written, and regardless whether they belong to the
92 system itself or are accessible user journals.</para>
94 <para>All users are granted access to their private
95 per-user journals. However, by default only root and
96 users who are members of the <literal>adm</literal>
97 group get access to the system journal and the
98 journals of other users.</para>
102 <title>Options</title>
104 <para>The following options are understood:</para>
108 <term><option>--help</option></term>
109 <term><option>-h</option></term>
111 <listitem><para>Prints a short help
112 text and exits.</para></listitem>
116 <term><option>--version</option></term>
118 <listitem><para>Prints a short version
119 string and exits.</para></listitem>
123 <term><option>--no-pager</option></term>
125 <listitem><para>Do not pipe output into a
126 pager.</para></listitem>
130 <term><option>--all</option></term>
131 <term><option>-a</option></term>
133 <listitem><para>Show all fields in
134 full, even if they include unprintable
135 characters or are very
136 long.</para></listitem>
140 <term><option>--follow</option></term>
141 <term><option>-f</option></term>
143 <listitem><para>Show only most recent
144 journal entries, and continously print
145 new entries as they are appended to
146 the journal.</para></listitem>
150 <term><option>--lines=</option></term>
151 <term><option>-n</option></term>
153 <listitem><para>Controls the number of
154 journal lines to show, counting from
155 the most recent ones. Takes a positive
156 integer argument. In follow mode
157 defaults to 10, otherwise is unset
158 thus not limiting how many lines are
159 shown.</para></listitem>
163 <term><option>--no-tail</option></term>
165 <listitem><para>Show all stored output
166 lines, even in follow mode. Undoes the
168 <option>--lines=</option>.</para></listitem>
172 <term><option>--output=</option></term>
173 <term><option>-o</option></term>
175 <listitem><para>Controls the
176 formatting of the journal entries that are
178 <literal>short</literal>,
179 <literal>short-monotonic</literal>,
180 <literal>verbose</literal>,
181 <literal>export</literal>,
182 <literal>json</literal>,
183 <literal>cat</literal>. <literal>short</literal>
184 is the default and generates an output
185 that is mostly identical to the
186 formatting of classic syslog log
187 files, showing one line per journal
188 entry. <literal>short-monotonic</literal>
189 is very similar but shows monotonic
190 timestamps instead of wallclock
191 timestamps. <literal>verbose</literal>
192 shows the full structered entry items
194 fiels. <literal>export</literal>
195 serializes the journal into a binary
196 (but mostly text-based) stream
197 suitable for backups and network
198 transfer. <literal>json</literal>
199 formats entries as JSON data
200 structures. <literal>cat</literal>
201 generates a very terse output only
202 showing the actual message of each
203 journal entry with no meta data, not
204 even a timestamp.</para></listitem>
208 <term><option>--quiet</option></term>
209 <term><option>-q</option></term>
211 <listitem><para>Suppresses any warning
212 message regarding inaccessable system
213 journals when run as normal
214 user.</para></listitem>
218 <term><option>--local</option></term>
219 <term><option>-l</option></term>
221 <listitem><para>Show only locally
222 generated messages.</para></listitem>
226 <term><option>--this-boot</option></term>
227 <term><option>-b</option></term>
229 <listitem><para>Show data only from
230 current boot.</para></listitem>
234 <term><option>--directory=</option></term>
235 <term><option>-D</option></term>
237 <listitem><para>Takes an absolute
238 directory path as argument. If
239 specified will operate on the
240 specified journal directory instead of
241 the default runtime and system journal
242 paths.</para></listitem>
246 <term><option>--new-id128</option></term>
248 <listitem><para>Instead of showing
249 journal contents generate a new 128
250 bit ID suitable for identifying
251 messages. This is intended for usage
252 by developers who need a new
253 identifier for a new message they
254 introduce and want to make
255 recognizable. Will print the new ID in
256 three different formats which can be
257 copied into source code or
258 similar.</para></listitem>
265 <title>Exit status</title>
267 <para>On success 0 is returned, a non-zero failure
268 code otherwise.</para>
272 <title>Environment</title>
276 <term><varname>$SYSTEMD_PAGER</varname></term>
277 <listitem><para>Pager to use when
278 <option>--no-pager</option> is not given;
279 overrides <varname>$PAGER</varname>. Setting
280 this to an empty string or the value
281 <literal>cat</literal> is equivalent to passing
282 <option>--no-pager</option>.</para></listitem>
288 <title>Examples</title>
290 <para>Without arguments all collected logs are shown
293 <programlisting>journalctl</programlisting>
295 <para>With one match specified all entries with a field matching the expression are shown:</para>
297 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service</programlisting>
299 <para>If two different fields are matched only entries matching both expressions at the same time are shown:</para>
301 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097</programlisting>
303 <para>If two matches refer to the same field all entries matching either expression are shown:</para>
305 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _SYSTEMD_UNIT=dbus.service</programlisting>
307 <para>If the separator "<literal>+</literal>" is used
308 two expression may be combined in a logical OR. The
309 following will show all messages from the Avahi
310 service process with the PID 28097 plus all messages
311 from the D-Bus service (from any of its
314 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097 + _SYSTEMD_UNIT=dbus.service</programlisting>
319 <title>See Also</title>
321 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
322 <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
323 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
324 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
325 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>