Check for old file with non zero size

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
Geert
Posts: 7
Joined: Wed Apr 16, 2014 7:26 am

Check for old file with non zero size

Post by Geert »

Hi,
I need to configure a test for existence of old file ( more than 2 hours) and non empty. the application that removes and process the files isn't taken empty files, so it is normal that empty files exists.

best regards
Geert
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You need custom script and Shell Script test method.
Something like

Code: Select all

const statusAlive       = "scriptRes:Host is alive:"
const statusDead        = "scriptRes:No answer:"
const statusUnknown     = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk          = "scriptRes:Ok:"
const statusBad         = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"


Dim fso, f, f1, bad1, difflimit

Set objArgs = WScript.Arguments
if objArgs.Count<1 then
  WScript.StdOut.Write statusUnknown & "required parameters: <path to folder> [<threshold in min>]"
  Wscript.Quit
End if

difflimit = 120
if objArgs.Count>1 then
   difflimit = int(objArgs(1))
End if


Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(objArgs(0))
Set fc = f.Files

bad1 = 0
For Each f1 in fc
  if f1.size >0 then
     diff = DateDiff("n", f1.DateLastModified, Now())
     if diff > difflimit then
        bad1 = 1
        WScript.StdOut.Write statusBad & f1.name
        EXIT FOR
    end if
  end if
Next
if bad1=0 then 
   WScript.StdOut.Write statusOk
end if
Regards
Alex
Geert
Posts: 7
Joined: Wed Apr 16, 2014 7:26 am

Post by Geert »

:) thx, I will create the script.
Post Reply