Before installing, verify if jstack is already available on your system by checking the version: jstack -version Use code with caution.
for i in 1..5; do jstack -l 12345 > thread_dump_$(date +%H%M%S).txt sleep 5 done install jstack on ubuntu
This command will output the path to the jstack command, usually /usr/lib/jvm/java-8-oracle/bin/jstack or similar. Before installing, verify if jstack is already available