- Linux - Misc notes for various distros that I use
- Table of contents
- systemd
- systemd-analyze
- unit files
- journalctl
- Show kernel log messages with an ERROR priority
- Show log messages with an INFO priority since the last boot
- Show ALL log messages between a time range
- Force time (shown in local time by default) to be displayed in UTC
- List messages for a specific systemd unit (e.g.,
rsyslog
) - "Tail" messages for a specific systemd unit (e.g.,
rsyslog
) - Show messages from most recent boot
- Ubuntu
- References
This tool can be used to display the startup time for various units. This information helps to pinpoint delays in the startup process.
From the manual page:
This command prints a tree of the time-critical chain of units (for each of the specified UNITs or for the default target otherwise). The time after the unit is active or started is printed after the "@" character. The time the unit takes to start is printed after the "+" character. Note that the output might be misleading as the initialization of services might depend on socket activation and because of the parallel execution of units.
Examples:
-
sudo systemd-analyze critical-chain
- overall causes of boot delay
-
sudo systemd-analyze critical-chain rsyslog.service
- display "critical-chain" for specific unit
-
sudo systemd-analyze critical-chain rsyslog.service docker.service
- display "critical-chain" for specific units
systemctl edit rsyslog.service
This creates a /etc/systemd/system/rsyslog.service.d/override.conf
file with
settings enterered via the interactive editor that is opened (likely
determined via $EDITOR
environment variable).
You can also create multiple "drop-in" files (aka, "drop-ins") manually to override specific settings.
sudo systemctl revert
As noted by Stephen Kitt (StackExchange member):
This reverts the given unit to its vendor configuration, deleting all overrides. (It will also restore the unit's properties to their defaults, and unmask it if it was masked by the administrator.)
sudo journalctl -p err -k
sudo journalctl -p info -b
sudo journalctl --since "2018-07-15 15:00:00" --until "2018-07-15 16:00:00"
The --since
and --until
options can be used together (as shown here)
or separately as needed for the desired effect.
sudo journalctl --utc
sudo journalctl -u rsyslog.service
sudo journalctl -f -u rsyslog.service
Specific service:
sudo journalctl -b -u nginx.service
Everything:
sudo journalctl -b
/etc/environment
- Common/central location for setting environment variables
- Example:
ES_HEAP_SIZE="512M"
- Pro Linux System Administration
- https://askubuntu.com/questions/995711/where-can-i-find-the-boot-log
- https://unix.stackexchange.com/questions/398540/how-to-override-systemd-unit-file-settings
- https://unix.stackexchange.com/questions/449051/systemd-delete-overrides
- https://www.freedesktop.org/software/systemd/man/systemd-analyze.html