I have an email archiving application on a Windows 2003 server that requires a lot more manual intervention than I prefer. As the application moves the mail messages throughout it’s various directory queues, sometimes it experiences an event that causes processing to halt. This results in a particular directory filling up until an administrator manually clears out the queues. The last time this happened we had 75,000 files, 10GB worth of messages we had to remove and recover by hand.
REM delete existing mailarch1file.txt file if exist mailarch1file.txt del mailarch1file.txt REM determine if files are queued using dir and output results to mailarch1file.txt e:\msw\internet\pending /A-D /B mailarch1file.txt REM If mailarch1file.txt is empty (EQU 0), files are not queued For %%R in (mailarch1file.txt) do if %%~zR EQU 0 goto nofiles REM delete existing results.txt file if exist results.txt del results.txt REM combine message file mailarch1fail.txt with results of mailarch1file.txt into results.txt copy /B mailarch1fail.txt + mailarch1file.txt results.txt REM email notification that files are queued in directory e:\msw\internet\pending REM notification to technical support using vmailer.exe that mailarch1 may be failing vmailer.exe results.txt 172.17.61.83 firstname.lastname@example.org email@example.com goto exitscript :nofiles REM email notification no files are queued in directory REM notification to technical support using vmailer.exe that mailarch1 is okay vmailer.exe mailarch1isok.txt 172.17.61.83 firstname.lastname@example.org email@example.com :exitscript REM exit script exit
If the DIR command’s output file mailarch1file.txt is empty, a notification text file mailarchisok.txt is emailed to myself that states the server is okay.
To: firstname.lastname@example.org From: email@example.com Subject: mailarch1 may be failing mailarch1 DOES have messages queued in the E:\MSW\Internet\PENDING directory
To: firstname.lastname@example.org From: email@example.com Subject: mailarch1 is okay mailarch1 DOES NOT have messages queued in the E:\MSW\Internet\PENDING directory
Finally, I used the Windows schtasks command line utiliy to run c:\chksize.cmd daily at 4pm. The task, named chksize4pm runs as as the firstname.lastname@example.org user with a password of 3rv1c3.
This is a single command that may have wrapped in your browser.
schtasks /create /S \\mailarch1 /U email@example.com /P $3rv1c3 /SC Daily /TN chksize4pm /TR c:\chksize.cmd /ST 16:00