8/29/2007

Batch Processes


I recently have found myself running batch processes scanning inventory on long lists of machines. To have more control I usually generate a list of IP's or machine names and use it as an input file to my process.
It is obvious after the fact, but I often don't think of it until I've wasted time on something taking too long -- things go faster if they are broken up into groups and processed in parallel.
I need to spend some time to make up a script to automate this, but what I do is:
- Create folders 0 - 9 beneath a process folder.
- Copy the script to each folder.
- Break up my input file of items to process into 10 equal in.txt files and put one in each folder.
- I generally have the script create an output file such as out.txt
- Run the script redirecting output to stdout.txt
- Tile them all on my second monitor and watch each for errors or a Complete! message.
- Run a script like the one below to consolidate the logs.

REM collectLOG.cmd
del temp\*.* /y
For /d %%p in (*) do copy "%%p\stdout.txt" "temp\%%p.log"
copy temp\*.log final\discovery.log

- Run a script like the one below to consolidate the output.

REM collectCSV.cmd
For /d %%p in (*) do copy "%%p\out.txt" "final\%%p.csv"

Labels:

12/04/2006

Hey, Scripting Guy! How Can I Delete All the .BAK Files in a Folder That Are More Than 7 Days Old?:
"dtmDate = Date - 7

strDay = Day(dtmDate)

If Len(strDay) < 2 Then
strDay = '0' & strDay
End If

strMonth = Month(dtmDate)

If Len(strMonth) < 2 Then
strMonth = '0' & strMonth
End If

strYear = Year(dtmDate)

strTargetDate = strYear & strMonth & strDay

strComputer = '.'

Set objWMIService = GetObject('winmgmts:\\' & strComputer & '\root\cimv2')

Set FileList = objWMIService.ExecQuery _
('ASSOCIATORS OF {Win32_Directory.Name='C:\Scripts'} Where ' _
& 'ResultClass = CIM_DataFile')

For Each objFile In FileList
strDate = Left(objFile.CreationDate, 8)
If strDate < strTargetDate Then
If objFile.Extension = 'bak' Then
objFile.Delete
End If
End If
Next"

Labels: , ,

9/29/2006

Windows::Management


Find how long since you last restarted:
systeminfo | find "Up Time"

Labels: , , , ,