:runprint
echo .
echo 创建堆栈存放的目录......
echo .
set runtime=%date:~0,10%_%time:~0,2%_%time:~3,2%_%time:~6,2%
set targetpath=JAVA_JDK_PRINT_FILE\%date:~0,10%
if not exist %targetpath% (md %targetpath%)
REM 检测文件大小
set heapfile=%targetpath%\堆栈_%runtime%.txt
for /f "delims=" %%a in ('dir /b /s "%heapfile%"') do (
rem 当文件大小为0,表示输入的进程号不存在
if %%~za==0 (
del /s /q %heapfile%
REM set /p noexist=进程号不存在,打印失败,是否重新打印[Y],退出[Q]
REM if /i %noexist% equ q goto end
REM if /i %noexist% equ y goto choiced
)
)
echo 1打印进程堆栈(heap)结束
echo .
echo .
echo 等待60秒后重新打印一次,如果不想继续打印,请直接关闭程序
REM 设置等待60秒进行重打印
ping -n 60 127.0.0.1 >nul
goto runprint