473,749 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wake up on file (inode) change (again)

guys,

I need one more hint on this. I feel I am not tackling this
in a php'ish way.

I've been asking before, in this NG, how to monitor a
(semaphore-like) file for timestamp changes, other than doing
a (sleep + filectime) loop.

The comments I received suggested using external tools, such as
famd, inotify or dazuko (thanks for the pointers).

The problem with those is that, on shared hosting servers, either they
don't run, or php is not allowed to use them.

Now what about having

1) the loop: while (1) { sleep(30); if (filectime(x)!= y) break; }
---obvious disadvantage: the monitoring script may wakeup with a delay of
up to 30 seconds---

---plus---

2) the option to wake up the monitor script, using sysv messaging where it
works, as soon as the file has been changed (by having whoever changed it
send a 'wakeup' message).

So, the sleep(30) loop would be a fallback option for systems where
sysv messaging is not available.

Let me rephrase the idea:

1.) Script A changes a file. It sends a wakeup message with msg_send
2.) Script B waits for the file to change, so it can do something with
it, but looks at the file's timestamp only once in 30 seconds
3.) Script B also listens for messages and, if sysv messaging is available
on that server, may wake up before the 30 seconds interval has passed

Is this smart, or am I only trying to be clever here?
msg_receive can either wait forever, or just go on, but it has no timeout
option. So I don't see how to combine "sleeping" and "listening" , other
than using a loop again, that would eat away CPU time for nothing.

Is there a way to have msg_recive run in blocking mode, but time out
after XX seconds?

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

Dec 30 '06 #1
1 1968

Johannes Kiehl wrote:
The comments I received suggested using external tools, such as
famd, inotify or dazuko (thanks for the pointers).

The problem with those is that, on shared hosting servers, either they
don't run, or php is not allowed to use them.
Most shared host servers will let you define a cron job, no?
Sounds like a good candidate for cron and a bash or perl script.

Dec 30 '06 #2

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

Similar topics

18
9113
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 data, imports it into a mySQL database and deletes the .csv-file after the import. so far, so good. but in some cases the cronjobs starts running when the file is not completely
4
1407
by: siliconmike | last post by:
What would happen on Linux if: $F=fopen("hello","wb"); lock $F write to $F rename "hello" as "mango" close $F Will mango contain upto date data ? Or will the rename cause it to contain incomplete data ?
22
2906
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 HTML template is processed by a WebCharm-aware web server, the content of my_include_file.txt is inserted at the tag location. This work very much like the SSI #include tag. However, you have more control
11
26248
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 it doesn't look like it thanks hilz
33
2360
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 implementation. The solution is in the tutorial for lcc-win32 (http://www.cs.virginia.edu/~lcc-win32) page 331.
6
5301
by: Kiran | last post by:
Hi, I have program, which opens file at the startup and logs error messages to the file, file handle is closed at the end of the program. However if file is deleted in-between, program do not report any error while writing to the open file handle. On Windows, file shows-up again in explorer and automatically deleted finally when program ends. On Unix, same thing happens if file is on nfs mounted drive, but in this case, actual file is...
5
4141
by: s99999999s2003 | last post by:
hi this is pertain to unix environment. is it possible to remove a file by it's inode and not it's filename using Python? Just curious... thanks.
2
2184
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 file(newsscroller.js) in my ASP page, everything works great in a normal HTML page, I can see the scroller just fine, but in an ASP page it just does not show, I get some error message that the control has not been initialize, so far I've been...
8
12018
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 Ext2 partition is split into block groups, each of which has the layout shown in Image 2. As you will notice from the figure, some data structures must fit in exactly one block, while others may require more than one block. All the block groups...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.