PHP Inotify Non-blocking way
Posted
by
demic0de
on Stack Overflow
See other posts from Stack Overflow
or by demic0de
Published on 2012-10-29T14:17:13Z
Indexed on
2012/12/07
11:04 UTC
Read the original article
Hit count: 138
I am reading a file in linux which is a log file that keeps on updating weather the file has changed and output it to the webpage. i do it using php inotify but my problem is that it is blocking.
How can i make php inotify non-blocking so i can do other stuff while it is monitoring the text file?.
<?php
$fd = inotify_init();
$watch_descriptor = inotify_add_watch($fd, '/tmp/temp.txt', IN_MODIFY);
touch('/tmp/temp.txt');
$events = inotify_read($fd);
$contents = file_get_contents('/tmp/temp.txt');
echo $contents;
inotify_rm_watch($fd, $watch_descriptor);
fclose($fd)
?>
Or can i do this in java?..Thanks.
© Stack Overflow or respective owner