• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

journalctl Command Examples in Linux

by admin

The journalctl command enables you to view and query log files created by the journal component of the systemd suite. Log information is collected and stored via the systemd journald service. You can use journalctl to print the entire journal log, or you can issue various options with the command to filter the log in a variety of ways, such as matching a service name or only printing messages matching the specified severity level.

The journald service is often used in conjunction with a traditional syslog daemon such as syslogd or rsyslogd. The settings for journald are configured in the /etc/systemd/journald.conf file.

Syntax

The syntax of the journalctl command is:

# journalctl [options] [matches]

journalctl Command Options

The journalctl utility provides a number of options for querying journald log data. Some of the frequently used options are listed in the following table.

Option Used To
-n {number of lines} Specify the number of lines of journal logs to display.
-o {output format} Specify the format of the output. For example: short, verbose, or export.
-f Display the most recent journal entries, and continuously update the display with new entries as they are added to the journal.
-p Filter journal log output by severity (alert, err, warning, notice, info, etc.).
-u Filter journal log output by the specified unit, such as the name of a service.
-b [boot ID] Show log message from the current boot only, or the boot ID specified.

journalctl Command Examples

1. Show all messages with priority level 3 (errors) from this [b]oot:

# journalctl -b --priority=3

2. Show all messages from last [b]oot:

# journalctl -b -1

3. Delete journal logs which are older than 2 days:

# journalctl --vacuum-time=2d

4. [f]ollow new messages (like `tail -f` for traditional syslog):

# journalctl -f

5. Show all messages by a specific [u]nit:

# journalctl -u unit

6. Filter messages within a time range (either timestamp or placeholders like “yesterday”):

# journalctl --since now|today|yesterday|tomorrow --until YYYY-MM-DD HH:MM:SS

7. Show all messages by a specific process:

# journalctl _PID=pid

8. Show all messages by a specific executable:

# journalctl path/to/executable

Filed Under: Linux

Some more articles you might also be interested in …

  1. Archiving Failures with ORA-16038, ORA-19504, ORA-00312
  2. How to run rsyslog as a non-root user in CentOS/RHEL 7
  3. route: command not found
  4. bsdtar command – Read and write tape archive files
  5. How to get Fibre Channel HBA information from Linux SOSreport
  6. mkdir and rmdir Command Examples in Linux
  7. How To Configure Restricted Bash Shell in Linux
  8. Understanding rsyslog Filter Options
  9. How to configure iSCSI Initiator (client) in CentOS / RHEL 6
  10. do-release-upgrade Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright