don't use PHP

Systems like Windows and GNU/Linux have somesort of "listener".
In that respect nothing happens until the system gets a notification of file changes. Then the sytem will send a message to your application that "something" has changed.
As an example (that i know of):
SHChangeNotifyRegister Function ()