バッチコマンド ちょっこっとメモ

シェアする

どうも、よく要りようになるので、メモまで。

日付文字列の作成

    set date_tmp=%date:/=%
    set time_tmp=%time: =0%
    set yyyy=%date_tmp:~0,4%
    set yy=%date_tmp:~2,2%
    set mm=%date_tmp:~4,2%
    set dd=%date_tmp:~6,2%
    set hh=%time_tmp:~0,2%
    set mi=%time_tmp:~3,2%
    set ss=%time_tmp:~6,2%
    set sss=%time_tmp:~9,2%
    set datetime=%yyyy%%mm%%dd%%hh%%mi%%ss%%sss%
    set time_tmp=
    set date_tmp=

JRE8系起動

    set GC_LOG=jvmgc.log
    set JRE=`C:\Program Files\Java\java1_8_0-45\bin\javaw.exe`
    set DBG=-Xloggc:%GC_LOG% -XX:+PrintGCTimeStamps -XX:+PrintGCDetails
    set GC=-XX:+UseG1GC -XX:MaxGCPauseMillis=200
    set MEM=-Xms1G -Xmx1G
    set JAR=hogehoge.jar
    set cmd=%JRE% -client %DBG% %GC% %MEM% -jar `%JAR%`
    start `` %cmd%

JRE7系起動

rem ******
    set HOME=%CD%
    set GCLOG=%datetime%_jvmgc.log
 
rem ******
    set JRE=`C:\Program Files\Java\jre7\bin\javaw.exe`
    set DBG1=-Xloggc:%GCLOG% -XX:+PrintGCTimeStamps -XX:+PrintGCDetails
    set DBG2=-XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution
    set DBG3=-XX:+TraceGen0Time -XX:+TraceGen1Time
    set GC=-XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseConcMarkSweepGC
    set MEM1=-Xms128m -Xmx1280m
    set MEM2=-XX:PermSize=32m -XX:MaxPermSize=128m
    set MEM3=-XX:NewRatio=2
    set MEM4=-XX:SurvivorRatio=6
    set JAR=%HOME%\app.jar
 
    set MEM=%MEM1% %MEM2% %MEM3% %MEM4%
    set DBG=%DBG1% %DBG2% %DBG3%
 
    set cmd=%JRE% -client %DBG% %GC% %MEM% -jar %JAR%
    start /high `` %cmd%