I would try to monitor the action performed on a thread something like tail command. And it should print the stackTrace of the thread (whose thread id is known).
I could print the stack trace of all the threads which is currently running under the java process like the following
pid=$(ps -ef |grep 'catalina' | grep java | awk ' { print $2 } ');
eval '/home/jdk/bin/jstack -F $pid' > stack_trace.txt
But I need to print stack trace of the thread whose thread id is known.
Any help in this regard is most welcome. Thanks in advance :)
Can you try to see if below works for you.
Which will print something like below