Skip to content

Instantly share code, notes, and snippets.

@mosra
Last active April 24, 2024 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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.
#
# 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