You are here: Re: monitor file (inode) changes effectively, how? « PHP Programming Language « IT news, forums, messages
Re: monitor file (inode) changes effectively, how?

Posted by Moot on 12/21/06 15:34

Johannes Kiehl wrote:
> Hi,
>
> I want a PHP script to "wake up" as soon as a file in a directory has been
> modified (by some other script). The obvious solution that comes to mind
> would be a ( readdir, filectime, maybe sleep ) loop, but I am concerned
> about CPU and filesystem load.
>
> Any recommendations?
>
> thanks to y'all,
> Johannes

I did something like this once. Keep in mind, though, that this was
only a small piece of a much larger school project and thus, not
perfectly designed and may not have scaled effeciently in the end. It
was also designed for *BSD. It assumes you have complete control of
your server and aren't on a shared environment (shared hosts may not
let you do it).

I wrote a system daemon in C that attached itself to the FAM (File
Alteration Monitor, i think it stands for). You can register with FAM
to have it tell you when something happens to individual files, or a
whole directory structure. The daemon would just run in the background
and when FAM detected a change, the daemon would log the file and what
happened. I then had a php script run periodically via cron that
parsed the log and performed whatever actions needed to occur. If time
is critical, then you could easily modify this scenario to have the
daemon call the php script directly instead of waiting.

This worked very well for our limited needs, but if I were going to
reimplement the same thing in a production environment, I would
extensively test the heck out of it.

- Moot

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация