Helpful Information
 
 
Category: Software Design
Directory polling?

I'd like to have a program (daemon, service)poll a folder and do some action on it's content.
How can I do this in java, php, python ... anything?
Thanks in advance for your help!

The easiest way is probably to write script which does this, then run it on regular intervals using cron (if on unix). I don't know what you have to use on windows, but I'm sure a similiar tool is available.

Well, there is plenty of such programs, but they are all commercial.
I need a service/daemon because it has to poll the directory "continuously", and I don't think that a cron that runs every 5 sec. would be right.
Do you know of any opensource project of this kind? Or a tutorial about building a service/daemon?
Regards.

Originally posted by pabloj
I need a service/daemon because it has to poll the directory "continuously"

So basically you want to "hook up" the OS functions manipulating with directory files (creating/modifying),etc. ?

Well, I guess that's just a program which does something every 5 seconds and sleeps for the rest of the time... You could even use a simple PHP script for that, although it's probably better to write it in C to avoid wasting resources:


while(true) {
//Poll directories
sleep(5);
}

Thanks for your help, I've even found another example in vb, but I'm gonna try with Python.










privacy (GDPR)