Re: 'file changed'-event
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 28 Dec 2005 16:09:19 GMT
Michael Goerz <news2132@xxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
> Hi,
>
> I'm trying to execute a sub whenever a certain file on the disk changes.
> Currently, I'm doing this with an infinite loop that checks the modify
> time (stat("$file"))[9]. While this works in principle, the infinite
> loop drives the CPU crazy and speeds up the fan (very annoying).
>
> Can I implement this with an event-based approach that doesn't drive up
> my CPU? How?
Unless your file system supports events you'll ultimately have to watch
the file. However, doing so in a tight loop is useless. Presumably the
file system's resolution is one second, so you should only stat the file
once a second. If you don't need maximum resolution make the intervals as
long as reasonable. That will make the load tolerable.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- Follow-Ups:
- Re: 'file changed'-event
- From: Veli-Pekka Tätilä
- Re: 'file changed'-event
- From: Michael Goerz
- Re: 'file changed'-event
- References:
- 'file changed'-event
- From: Michael Goerz
- 'file changed'-event
- Prev by Date: 'file changed'-event
- Next by Date: Re: 'file changed'-event
- Previous by thread: 'file changed'-event
- Next by thread: Re: 'file changed'-event
- Index(es):
Relevant Pages
|
|