Last active
March 10, 2021 06:32
-
-
Save jdbranham/a8aba33153e469101d65665757b0c421 to your computer and use it in GitHub Desktop.
Helpful JVM CLI Commands
This file contains hidden or 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
| # source - https://stackoverflow.com/a/52897164/1308685 | |
| # Get total Java memory usage from PS | |
| ps -eo size,pid,user,command --sort -size | egrep -i "*/bin/java *" | egrep -v grep | awk '{ hr=$1/1024 ; printf("%.2f MB ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | cut -d "" -f2 | cut -d "-" -f1 | |
| # Get heap size in MB | |
| jstat -gc $(ps axf | egrep -i "*/bin/java *" | egrep -v grep | awk '{print $1}') | tail -n 1 | awk '{split($0,a," "); sum=(a[3]+a[4]+a[6]+a[8]+a[10])/1024; printf("%.2f MB\n",sum)}' | |
| # Print Heap information | |
| jcmd pid GC.heap_info | |
| jcmd pid VM.system_properties | |
| jcmd pid VM.flags | |
| # source - https://stackoverflow.com/a/7448828/1308685 | |
| # Find recent modified files | |
| find $1 -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment