Skip to content

Instantly share code, notes, and snippets.

@athlan
Last active July 17, 2019 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athlan/5b895d51a10ad1067d9bdde6de8e6152 to your computer and use it in GitHub Desktop.
Save athlan/5b895d51a10ad1067d9bdde6de8e6152 to your computer and use it in GitHub Desktop.
Usefull linux commands

Most space-consuming directories

df -h .; du -sh -- * | sort -hr

Find files newer than..

find . -type f -newermt 2018-01-01

Sum up size from files from find:

find . -type f -newermt 2018-01-01 -printf "%s\n" -print0 | xargs -0 du -hc | tail -n1

Clean up files in directory and compress some

0 1 * * * find /some/path/to/dir -type f -mtime +30 -exec rm {} \; > /dev/null 2>&1
0 1 * * * find /some/path/to/dir -type f -mtime +8 -exec gzip {} \; > /dev/null 2>&1

Java expose jmx remote when not run with parameters

jcmd PID_HERE ManagementAgent.start jmxremote.port=SOME_PORT_HERE jmxremote.authenticate=false jmxremote.ssl=false

Java run profiler for many processes

jps | grep PROCESS_NAME | cut -d ' ' -f1 | sed -re 's/(.+)/jcmd \1 JFR.start duration=600s filename=~\/tmp\/server-\1.jfr/' | bash

Java run heapdumps for many processes

jps | grep PROCESS_NAME | cut -d ' ' -f1 | sed -re 's/(.+)/jmap -dump:format=b,file=server-heapdump-\1.hprof \1/' | bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment