最後のセルが始まるまでJournalctlのリスト

最後のセルが始まるまでJournalctlのリスト

ロードに失敗したサービスをデバッグするときに人々がしようとする一般的なタスクは、サービスが最後に開始された時刻のすべてのログを表示することです。

例えば、与えられた

Jul 25 08:18:20 raspberrypi ngrok[3105]: Incorrect Usage: flag provided but not defined: -log
Jul 25 08:20:04 raspberrypi systemd[1]: [email protected] holdoff time over, scheduling restart.
Jul 25 08:20:04 raspberrypi systemd[1]: Stopping Share local port(s) with ngrok...
Jul 25 08:20:04 raspberrypi systemd[1]: Starting Share local port(s) with ngrok...
Jul 25 08:20:04 raspberrypi systemd[1]: Started Share local port(s) with ngrok.
Jul 25 08:20:04 raspberrypi ngrok[5474]: t=2016-07-25T08:20:04+0000 lvl=warn msg="failed to get home directory, using $HOME instead" err="user: Current not implemented on linux/arm" $HOME=
Jul 25 08:20:04 raspberrypi ngrok[5474]: Failed to open log file '/dev/stdout': open /dev/stdout: no such device or address

その後のすべてのセリフを見たいですJul 25 08:20:04 raspberrypi systemd[1]: Starting Share local port...

と似ていますjournalctl --bootが、最後にサービスが開始された時刻から始まります。

それは可能ですか?

同様に--list-boots、systemctlがサービスを開始または停止するすべての時間を一覧表示するなどの機能を使用すると、私がjournalctl --last-start -u svc望む動作を模倣できます。

ベストアンサー1

残念ながら、この機能は現在サポートされていません。バラよりhttps://github.com/systemd/systemd/issues/1942

GitHubユーザーオオカミ夫 スクリプトを投稿しました非常に近い質問から:

#!/bin/bash
#

[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || :

# Timestamp when unit transitioned from inactive to active
since=$(systemctl show -p InactiveExitTimestamp "$1" | cut -f 2 -d '=' | cut -f 2-3 -d' ')
# or one minute if unset
since=${since:-1 min ago}

# Get prefix string that this units logs with: most robust
# https://github.com/systemd/systemd/issues/2913#issuecomment-219702148
id=$(systemctl show -p SyslogIdentifier "$1" | cut -f 2 -d '=')

# Get all raw output from unit since start, only from stdout&stderr
# Considering that backend only logs "bad" stack traces to stderr, this should
# always be relevant
service_trace=$(journalctl -o cat --since "$since" -t "$id")

おすすめ記事