Results 1 to 4 of 4
Hello everyone, first time poster and I have a question for you.
I'm trying to run a php script whenever a specific directory's files and/or folders are edited/added/deleted.
It has ...
- 11-17-2011 #1Just Joined!
- Join Date
- Nov 2011
- Posts
- 2
Help: Execute php script on directory content change.
Hello everyone, first time poster and I have a question for you.
I'm trying to run a php script whenever a specific directory's files and/or folders are edited/added/deleted.
It has to be run through CLI.
Any suggestions on how to do this?
Thanks!
- 11-17-2011 #2
The simplest way would be to use cron.
linux user # 503963
- 11-17-2011 #3Just Joined!
- Join Date
- Nov 2011
- Posts
- 2
- 11-17-2011 #4
Hi,
Inotify is what you want.
There are several userland tools.
1) incrond
This is a relatively simple tool. Similar to cron but fs event based.
It can watch multiple directories, but not recursive.
Once one or multiple events such as IN_CLOSE_WRITE is/are received, it executes a given script/tool.
Note: incrond is very picky about tabs/white spaces/line feeds.
- Only use *one* space to separate the parts of a incrontab.
- Never use tabs (On that one I agree, actually
)
- There needs to be a line feed at the end of the file
2) lsyncd
Contrary to what the name suggests, its capabilities exceed file syncing.
By far.
It can watch directories recursively.
The actions are controlled via lua, aka it is very versatile.
3) PHP Pecl Inotify
This would have the advantage to not mix multiple languages.
But then again -in your case- you would need to run your php application as a daemonYou must always face the curtain with a bow.


Reply With Quote
