linux windows下怎么获取当前进程的cpu和内存的消耗的信息
日期:2018/1/22
运行这个批处理
或者把它加到计划任务里面
[code=BatchFile]@echo off
set DstFile=C:\test\cpu_mem.log
if not exist %DstFile% (
type nul>"%DstFile%"
)
:cpu
for /f "tokens=2 delims==" %%a in ('wmic path Win32_PerfFormattedData_PerfOS_Processor get PercentProcessorTime /value
^| findstr "PercentProcessorTime"') do (
set UseCPU=%%a
goto :mem
)
:mem
for /f "tokens=2 delims==" %%a in ('wmic path Win32_PhysicalMemory get * /value ^| findstr "Capacity"') do (
set TalMem=%%a
)
for /f "tokens=2 delims==" %%a in ('wmic path Win32_PerfFormattedData_PerfOS_Memory get * /value
^| findstr "AvailableBytes"') do (
set UseMem=%%a
)
:show
>>"%DstFile%" echo CPU使用率:%UseCPU%%%
>>"%DstFile%" echo 物理内存总量:%TalMem%
>>"%DstFile%" echo 当前可用内存:%UseMem%[/code]