Created
February 15, 2019 23:58
-
-
Save aniketbhatnagar/13014f963cf8e9781b834992770aedda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: ./profile.sh pid output.txt | |
PROFILED_PID=$1 | |
OUTPUT_FILE=$2 | |
echo "Getting stacktraces from process $PROFILED_PID... Will stop on ^C or when the process exits." | |
rm -f "$OUTPUT_FILE" | |
while true; do | |
jstack "$PROFILED_PID" >> "$OUTPUT_FILE" && sleep 0.5 || break | |
done | |
echo | |
echo "Done! Stacks saved to $OUTPUT_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment