top -p 8254 | tail -n +6
The command above monitors the process Elasticsearch and only outputs information about elasticsearch
top -b -n 10 -p 8254 >> /home/search/Downloads/file3.txt
Command above monitors Elasticsearch (all threads summerized under pid 8254) with the top command and runs 10 iterations of top ... and prints this information in the following file
top -bn 10 -p 8254 | grep "^ " | awk '{ printf("%-8s %-8s %-8s %-8s %-8s %-8s %-8s %-8s %-8s %-8s %-8s %-8s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); }' >> /home/search/Downloads/file6.txt
The command above creates the following output for 10 iterations of command top on elasticsearch
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.90 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.90 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.90 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.90 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.90 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.90 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.90 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,3 6,2 1:25.91 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.91 java
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8254 elastic+ 20 0 6970340 2,444g 20492 S 0,0 6,2 1:25.91 java
alternativly use command watch and ps or something
ps awk or htop to list all processes.