11
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JVMオプションのJavaコマンド起動スクリプトのひな形

Last updated at Posted at 2014-12-08
java -XX:+PrintFlagsFinal -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions

で状態の確認。

ひな形

バッチ処理のjarを想定。Java7で使用中。Java8では未確認。
-Xmxやら-XmsやらはJVM_TUNEに書く、けど大抵はJVMが自動でよしなに設定してくれるんじゃないかな。

run.sh
function run_batch() {
  local TODAY=$(date +%Y_%m_%d)
  local JVM_LOG_DIR="/var/log/app_batch"

  local JVM_TUNE=""
  local JVM_GC_LOG="-Xloggc:$JVM_LOG_DIR/gc.log.$TODAY \
   -XX:+PrintGCDetails -XX:+PrintGCDateStamps \
   -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=10M"
  local JVM_DUMP="-XX:+HeapDumpOnOutOfMemoryError \
   -XX:HeapDumpPath=$JVM_LOG_DIR/ \
   -XX:ErrorFile=$JVM_LOG_DIR/hs_err_pid%p.log"
  local JVM_OPTS="$JVM_TUNE $JVM_GC_LOG $JVM_DUMP"

  java $JVM_OPTS -jar batch-${VER}.jar
  return 0
}

参考

11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?