SysAdmin‏ > ‏

Scripting

להלן הסקריפט אשר בודק גודל של ספרייה בשרת ושולחת מייל במידה וגודל הספרייה עולה על 2GB

echo off

rem This script monitors size of  folder
rem If it exceeds 2Gb, the script sends email

setlocal enabledelayedexpansion
set dir= D:\folder_name


set /a value=0 
set /a sum=0 
FOR /R %dir% %%I IN (*) DO ( 

set /a value=%%~zI/1024/1024
set /a sum=!sum!+!value!

)

echo %sum%Mb

if %sum% GEQ 2050 (


bmail -s open.smtp_relay.com -t admin@company.com,resposible_user@company.com  -f monitor_folder@my.server -h -a "Folder size exceeded 2GB" -b "Folder size is "%sum%"Mb. Please delete some files" -d

)

endlocal

כאן אני משתמש בתוכנה קטנה בשם bmail. להלן הקישור: http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm 


LiveJournal: igor_it