Software to monitor a folder for a lack of file modification based on timestamp?
July 20, 2010 12:11 PM   Subscribe

Software to monitor a folder and notify when a file is NOT modified recently?

We have a temperature probe that stores readings in a CSV file on a Windows network share.

The software is wonky, and sometimes stops recording. We would like software that would alert us when the files in this directory are NOT being updated. Is there software that would alert us as soon as a file's last-modified date becomes older than some value based on the current time?
posted by odinsdream to Computers & Internet (13 answers total) 1 user marked this as a favorite
 
I don't know of anything off-the-shelf, but a powershell script seems like it would work well for this - just have it run every n minutes and fire off an email if the file hasn't been modified.
posted by sanko at 12:21 PM on July 20, 2010


There is commercial software to do this but yeah, Nth the script idea.
posted by anti social order at 12:35 PM on July 20, 2010


Servers Alive can do this, and I believe as long as you are monitoring under ten items it is free. You can also have it send a keep-alive, so you know that the monitoring software is still running itself.
posted by kellyblah at 12:44 PM on July 20, 2010


A short VBScript running under Scheduled tasks should be extremely easy.
posted by wongcorgi at 12:48 PM on July 20, 2010


If you have cygwin with cron and exim installed, you could have a bash script running every n seconds that does something like this:

#!/bin/bash
[ ! -N file ] && cat "file has not been modified" | exim user@host

-N tests whether the file has been modified. "!" negates it.
posted by Cat Pie Hurts at 1:02 PM on July 20, 2010


If you have cygwin with cron

Cygwin cron is the service that fails inexplicably, leading to the temperature recording scripts to not run, leading to the files not updating.

I'm looking for a commercial piece of software that would monitor the CSV files, so that I don't need to continue this russian nesting doll scripting approach.
posted by odinsdream at 1:16 PM on July 20, 2010


Sounds like you need to have the original polling program written, not another program to monitor the CSV files.
posted by wongcorgi at 1:30 PM on July 20, 2010


wongcorgi: The polling isn't a program - it's a series of bash scripts. They are not failing - the cron service is failing. The bash scripts always work correctly as long as cron is running. cron fails randomly every two months or so. We don't have the resources to devote to figuring out why. All we need to do is know when it failed so someone can pop in and restart it.

I'm not sure this is relevant to the question, though, which is about Windows software to monitor a folder for files that haven't changed. The business process creating these files could change dramatically from what we currently use, which is why I asked this specific question, not a question about diagnosing cron failures.
posted by odinsdream at 1:41 PM on July 20, 2010


If that were my problem, I'd write a bash script to do the file check, and launch it periodically from a Windows scheduled task.
posted by flabdablet at 4:47 PM on July 20, 2010


This is a bit of a tangent, but would the bash scripts run under win-bash and UnxUtils? If they do, then you can ditch Cygwin cron altogether and just run them from a Windows scheduled task.

But yeah, short of that, a scheduled task wrapping a script of some sort seems like the answer to the problem.
posted by leo. at 6:45 PM on July 20, 2010


I would rewrite it as a batch file running under 'at'.

Secondly, I would use two checks: the time difference between the oldest and newest files in the directory, and a check between the current time and the time of the newest file. The second check is to ensure that the files are indeed getting updated at all, and the first checks for laggers within the directory.
posted by rhizome at 6:54 PM on July 20, 2010


This is really, really easy. Let me see what I can do.
posted by koeselitz at 9:11 PM on July 20, 2010


Okay; the thing is, I don't know visual basic for shit (and anybody who cares about their time and doesn't want to waste it probably hasn't learned it) but I do know about AutoHotkey, which is pretty good at scripting things like this in a Windows environment and so basic pretty much anybody can hack it.

Here's an AutoHotkey script that does what you want in 19 lines - that is, it asks for a file, asks for an amount of time you want the script to pause between checks, and then commences checking, quitting and showing a timestamp when the file doesn't change between checks:

FileSelectFile,file
InputBox,pause,Pause Time,Seconds to wait between checks:,,348,113,300,300
FileGetTime,time0,%file%,M
Loop,
{
Sleep,% pause * 1000
FileGetTime,time1,%file%,M
if % time0 = time1
{
FormatTime,time_f,%time1%,HH:mm.ss tt
msgbox, file unchanged`n[last change at %time_f%]
exitapp
}
else
{
continue
}
}
exitapp


Pretty simple. If you already know how often the file is supposed to be updated, that's an easy thing for me to hard-code so you don't have to enter it every time. Also, if you want this to do batch-checking (that is, you don't want to check just one file but a whole folder of files) that's pretty simple, too. I've checked, and this script runs on a trivial amount of memory – about 6.5 mb.

This would probably work pretty well. I don't know how well the Windows Scheduler works – if it's solid, you could write this script even shorter (like, as about two lines long) and then just schedule the check, so the script wouldn't have to run persistently at all.

Are you looking to check a whole folder full of files? Also, it sounds like you want something that will persistently do checks over weeks upon weeks at a time, right? As you put it, "every two months." It seems like it might be best just to write a very, very short AutoHotkey script, compile it as an .exe, and then schedule it to run.

Let me know if you want a compiled copy of the above script, or if you want a compiled copy of a simple checking script. It's pretty trivial.
posted by koeselitz at 9:55 PM on July 20, 2010


« Older old outboard motor controls qu...   |  I need low tech ideas to get m... Newer »
This thread is closed to new comments.