Skip to content

Instantly share code, notes, and snippets.

@mosra
Last active November 6, 2024 20:10
Show Gist options
  • Save mosra/85e2d89f8cc5a44a674723c0f7e6a78a to your computer and use it in GitHub Desktop.
Save mosra/85e2d89f8cc5a44a674723c0f7e6a78a to your computer and use it in GitHub Desktop.
Print a backtrace of the last failed command
#!/bin/bash
# Save into /usr/local/bin/bt and make the file executable. On Ubuntu you may
# need to additionally perform the following:
#
# sudo apt install systemd-coredump
#
# Calling `bt` then non-interactively prints a backtrace of last program that
# exited with a SIGABRT or SIGSEGV. Makes use of systemd's builtin coredumpctl,
# causes no core files littered around on the filesystem.
set -e
coredumpctl debug -q -A "-iex \"set pagination off\" -iex \"set style enabled on\" -iex \"set debuginfod enabled on\" -ex bt --batch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment