Created
February 20, 2015 22:51
-
-
Save kmark/7dbf864d7e0fa4bf35df to your computer and use it in GitHub Desktop.
Finds a running CLion instance and takes multiple jstack traces at a specified interval. Changing the regex should allow for use in any Java process that can be uniquely identified via jps.
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/bash | |
traces=10 | |
interval=5 | |
jps -mv | while read -r line; do | |
if [[ $line =~ ^([0-9]+).*clion.*$ ]]; then | |
printf "CLion running with PID %s\n" ${BASH_REMATCH[1]} | |
for ((i = 1; i <= $traces; i++)); do | |
printf "%d... " $i | |
jstack -l ${BASH_REMATCH[1]} > jstack-$i.txt | |
if (("$i" < "$traces")); then | |
sleep $interval | |
fi | |
done | |
printf "\n" | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment