PHP Inotify Non-blocking way
- by demic0de
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.