Skip to main content

Posts

Showing posts from February, 2020

Script to kill the SMTP service when the folders in mailroot reaches to a certain number

Hi All, Today I am going to give you a script . When the folders of SMTP service like pickup, badmail, Drop and queue becomes full or reaches to some number the below script will kill the SMTP process and will again start the process.  and a output log file will be created when the process is killed. Modify the below script as per you environment. @echo off set /a c=1 for /f %%i in ('dir C:\inetpub\mailroot\Pickup  ^| findstr /i /c:"file(s)"') do set count=%%i if %count% gtr 10 (      for /f "tokens=2 delims= " %%P IN ('tasklist /FO Table /M "SMTPSVC*" /NH ') DO (TASKKILL /F /PID %%P)     net start smtpsvc echo %date%      %time%       %count% - Pickup Folder has reached the limit >>"C:\smtp.log"      ) endlocal for /f %%i in ('dir C:\Inetpub\mailroot\Queue ^| findstr /i /c:"file(s)"') do set count=%%i echo count=%count% if %count% gtr 10   (      for /f "tokens=2 delims= "