

This is useful when sending logs to a log centralization or analysis service, since it makes them easier to parse.

The -r parameter shows journal entries in reverse chronological order, so the latest messages are printed first. In the command below, we are printing the last 50 messages logged within the last hour. Like the tail command, the -n switch will print the specified number of most recent journal entries. To stop following and return to the prompt, press Ctrl+C. To do this, add the -f switch, $ journalctl -fįor example, this command “follows” the mysql service log. Journalctl can print log messages to the console as they are added, much like the Linux tail command. $ journalctl -u rvice -u rvice Follow or Tail For example, if you want to see log entries for both nginx and mysql, the following command can be used. The -u switch can be used multiple times to specify more than one unit source. You can use the -since and -until switches here to pinpoint web server errors occurring within a time window. The command below will show all messages logged by the Nginx web server. To see messages logged by any systemd unit, use the -u switch. You can also use any format that follows the systemd.time specification. $ journalctl -since " 23:15:00" -until " 23:20:00"įor greater accuracy, format the date and time as “YYYY-MM-DD HH:MM:SS”. All messages logged on or after the since parameter and logged on or before the until parameter will be shown. The command below will show messages between two dates and times. To see messages logged in the last two days, the following command can be used. The following command shows journal messages logged within the last hour. To see messages logged within a specific time window, we can use the -since and -until options. The first field is the offset (0 being the latest boot, -1 being the boot before that, and so on), followed by a Boot ID (a long hexadecimal number), followed by the time stamps of the first and the last messages related to that boot. To list the boots of the system, use the following command. Here, we are retrieving messages from the last boot: $ journalctl -b -1 For example, the previous boot has an offset of -1, the boot before that is -2, and so on. You can view messages from an earlier boot by passing in its offset from the current boot. To limit the logs shown to the current boot, use the -b switch.

Journald tracks each log to a specific system boot. The cut-off portion can be viewed using the left and right arrow keys. Long entries are printed to the width of the screen and truncated off at the end if they don’t fit. You can navigate using the arrow keys, the Page Up/Page Down keys, and the space bar. Journalctl splits the results into pages, similar to the less command in Linux. The entries will start with a banner similar to this which shows the time span covered by the log. When run without any parameters, the following command will show all journal entries, which can be fairly long: $ journalctl
SCROLL REVERSER WINDOWS ALTERNATIVE FULL
To get a full listing of journalctl options, visit the journalctl man page. These methods can be used on their own or in combination with other commands to refine your search. In the following paragraphs, we’ll show you several ways of using journalctl to retrieve, format, and analyze your logs. Since journald stores log data in a binary format instead of a plaintext format, journalctl is the standard way of reading log messages processed by journald. Journalctl is a utility for querying and displaying logs from journald, systemd’s logging service.

