Skip to content

Commit

Permalink
Make calling of commands more consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaas committed Sep 22, 2020
1 parent ae8c354 commit 62151db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin/get-journald-logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Requires the 'jq' package to be installed.
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin
CUR_DIR=$(dirname $0)
STATE_DIR="${CUR_DIR}/../state"
STATE_FILE="${STATE_DIR}/journald.state"
Expand All @@ -22,14 +23,14 @@ update_state () {
if [ -s ${STATE_FILE} ]; then
# get state and logs
CURSOR=$(cat ${STATE_FILE})
/usr/bin/journalctl --after-cursor="${CURSOR}" --no-tail --no-pager -o json | /usr/bin/tee ${STATE_LOGFILE}
journalctl --after-cursor="${CURSOR}" --no-tail --no-pager -o json | tee ${STATE_LOGFILE}
update_state
fi


if ! [ -f ${STATE_FILE} ]; then
# no state (first run?); get logs of today
/usr/bin/journalctl --no-tail --since today --no-pager -o json | /usr/bin/tee ${STATE_LOGFILE}
journalctl --no-tail --since today --no-pager -o json | tee ${STATE_LOGFILE}
update_state
fi

Expand Down

0 comments on commit 62151db

Please sign in to comment.