Skip to content

Instantly share code, notes, and snippets.

@AJDurant
Created May 10, 2019 13:28
Show Gist options
  • Select an option

  • Save AJDurant/a0cdc566df5b494fa836e3c9c7481e45 to your computer and use it in GitHub Desktop.

Select an option

Save AJDurant/a0cdc566df5b494fa836e3c9c7481e45 to your computer and use it in GitHub Desktop.
Get all boot logs from journalctl and put them into a given dir by boot time
#!/bin/bash -ue
LOGDIR=$1
# The code point $'\342\200\224' is for the em dash
rm $LOGDIR/*.log
journalctl --list-boots --utc | awk -F $'\342\200\224' '{print $1}' | awk '{print $1, $4"_"$5"_"$6}' | xargs -n2 bash -x -c "journalctl --no-pager -b\$1 > $LOGDIR/\$2.log" bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment