bat文件启动或关闭其它windows服务

这个脚本主要用于自动化管理Nginx服务,包括强制停止Nginx进程,移动access.log和error.log到备份目录,并根据日期重命名。然后启动Nginx服务,并清理监听8088和8089端口的进程。最后,切换到E盘的ygt2和ygt3目录分别执行start.bat。
摘要由CSDN通过智能技术生成

taskkill /im nginx.exe /f
D:
move D:\heshuan\nginx-1.17.7\logs\access.log D:\heshuan\nginx-1.17.7\backuplog
move D:\heshuan\nginx-1.17.7\logs\error.log D:\heshuan\nginx-1.17.7\backuplog
cd D:\heshuan\nginx-1.17.7\backuplog
del /f /s /q "access%date:~0,4%-%date:~5,2%-%date:~8,2%backup.log"
del /f /s /q "error%date:~0,4%-%date:~5,2%-%date:~8,2%backup.log"
rename access.log "access%date:~0,4%-%date:~5,2%-%date:~8,2%backup.log"
rename error.log "error%date:~0,4%-%date:~5,2%-%date:~8,2%backup.log"
cd D:\heshuan\nginx-1.17.7
start nginx.exe
for /f "tokens=1-5 delims= " %%a in ('"netstat -ano|findstr "^:8089""') do taskkill /pid %%e
for /f "tokens=1-5 delims= " %%a in ('"netstat -ano|findstr "^:8088""') do taskkill /pid %%e
E:
cd E:\ygt2
call  start.bat
cd E:\ygt3
call start.bat

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值