473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

monitor file (inode) changes effectively, how?

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

--
Please don't send personal email to the From: address. -->>
ed tod iduej ta oj :siht rof bmud oot era stobmaps epoH <<--

Dec 21 '06 #1
2 1901
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

Dec 21 '06 #2
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
Dazuko, inotify, FAM - it kinda depends what you are running. Try Google for
more info.

C.
Dec 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
22
by: Long | last post by:
Problem: to insert the content of a file in an HTML document at a specific location. One possible way is to add a WebCharm tag like this: <%@charm:text 20 0 my_include_file.txt %> When the...
11
by: hilz | last post by:
Hi all: I have a FILE pointer that points to a file on disk (not any other io stream). is there a way to get the filename of that FILE? i thought it would be the _tmpfname part of the struct, but...
33
by: jacob navia | last post by:
Recently there was a discussion in this group about how to retrieve the file name given a FILE *. The question raised my curiosity, and after some research I have come up with a good...
25
by: vooose | last post by:
Suppose execution of a particular thread T1 hits Monitor.Enter(obj); //critical section and blocks at the first line. (ie someone else is in the critical section) Now suppose more threads...
14
by: MarcJ | last post by:
Hello, What I'm trying to do is monitor a log file for a certain line of text to be written to it. Once that text is written, I want to parse from that instance of the watched text until it...
2
by: verci | last post by:
Hi guys, sorry if this seems stupid but I'm a newbie, I'm running Windows XP Pro SP2, IE 7, VS2005, ASP.net 2.0 The problem is that I'm trying to display this news scroller made in a Javascript...
1
by: jcor | last post by:
Hi, I already posted a similar problem, but now I have more concrete ideas of what I need. I'm trying to build a "drop box" so I can be watching a directory and every time a file is created I'll work...
8
ashitpro
by: ashitpro | last post by:
Understanding Ext-2 file system:chapter 1 The first block in each Ext2 partition is never managed by the Ext2 filesystem, because it is reserved for the partition boot sector. The rest of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.