windows统计数据库连接数批处理及find和findstr查找命令使用--笔记

windows统计数据库连接数批处理及find和findstr查找命令并创建批处理bat脚本




@echo on

set   CurDate=%date:~0,10%

set   CurTime=%time%

set   hh=%CurTime:~0,2%

if   /i   %hh%   LSS   10   ( set   hh=0%CurTime:~1,1% )

set   mm=%CurTime:~3,2%

set   ss=%CurTime:~6,2%

set   CurDateTime=%CurDate%_%hh%:%mm%:%ss%

set   CurDateTime


d:

cd \

echo =================================================================== >>mysqlccount.txt

echo 统计数据库连接数 %CurDateTime% >>mysqlccount.txt

echo =================================================================== >>mysqlccount.txt

echo. >>mysqlccount.txt

netstat -an|findstr  /I  "10.10.10.189:3306 127.0.0.1:3306" >>mysqlccount.txt

echo. >>mysqlccount.txt

echo mysql数据库连接数为: >>mysqlccount.txt

netstat -an|findstr  /I  "10.10.10.189:3306 127.0.0.1:3306" |find /v /c "" >>mysqlccount.txt

echo. >>mysqlccount.txt

echo -------------------------------------------------------------------- >>mysqlccount.txt

echo. >>mysqlccount.txt

netstat -an|findstr  /I  "10.10.10.189:1433" >>mysqlccount.txt

echo. >>mysqlccount.txt

echo sqserver数据库连接数为: >>mysqlccount.txt

netstat -an|findstr  /I  "10.10.10.189:1433" |find /v /c "" >>mysqlccount.txt

echo. >>mysqlccount.txt


你可能感兴趣的:(windows,bat,find,批处理)