Posts

Showing posts from September, 2020

journalctl Notes

Show logs since a specific time journalctl --since yesterday journalctl --since "1 hour ago" journalctl --since "2020-09-03 12:34" Show logs for a specific systemd unit journalctl -u haproxy.service Show logs for several units together journalctl -u varnish.service -u hitch.service --since today Show logs by executable journalctl /usr/bin/bash Display kernel messages journalctl -k Output journal entires as JSON journalctl -b -u nobody -o json or formatted JSON journalctl -b -u nobody -o json-pretty Supported output formats: cat : Only the message field export : Binary format for backup or transfer json : One-line per entry standard JSON json-pretty : Human readable JSON json-sse : Server-sent event compatible JSON short : Default syslog style output short-iso : Default with ISO 8601 timestamps ( YYYY-MM-DDTHH:mm:SS+TZ ) short-monotonic : Default with monotonic timestamps since boot ( [ 1.817288] ) short-precise : Default with microsecond precision timestamps (

awk One-Liners

(This is a work in progress) Get the average of a column ls -l | grep -v total | awk -F' ' '{sum += $5 } END { print "AVG=", sum/NR }' Print a file with line numbers awk '{ print FNR "\t" $0 }' file Print number of lines in a file (analogous to wc -l ) awk 'END { print NR }'