Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8730839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:06:19+00:00 2026-06-13T09:06:19+00:00

I have program in linux which creates/modify a file when it detects a new

  • 0

I have program in linux which creates/modify a file when it detects a new connected socket. It logs the ip in that file and deletes it when the client is disconnected or disconnects..

In php i know inotify but it’s blocking and refreshes unlike java it doesn’t.. How can i do this with java and php so i can monitor a files in linux and update the website that a file in linux has been modified?

Thank you..

e.g in php..

<?php

$fd = inotify_init();

$watch_descriptor = inotify_add_watch($fd, '/tmp/devfile.txt', IN_MODIFY);

touch('/tmp/devfile.txt');

while(true){
$events = inotify_read($fd);

$contents =file_get_contents('/tmp/devfile.txt');

echo $contents;
}

$read = array($fd);
$write = null;
$except = null;

stream_select($read,$write,$except,0);


stream_set_blocking($fd, 0);

inotify_read($fd); 

$queue_len = inotify_queue_len($fd);

inotify_rm_watch($fd, $watch_descriptor);


fclose($fd);

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:06:20+00:00Added an answer on June 13, 2026 at 9:06 am

    I’m not sure what you mean by “java and php”, but if what you are looking for is a pure-java way to be notified of changes to the file, then you can use java.nio.file.Path and the WatchService api.

    Here is an explanation from the Oracle documentation of how it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a Linux program that runs in a while(true) loop, which waits
I have a linux C program that handles request sent to a TCP socket
see i have make one program which create one new file just using fopen()
I have a C++ program/Linux, which within 2-3 seconds of running starts spitting error
I have a python program that must work on Windows and Linux. There are
I have a small test program that creates millions of files (for testing purposes)
Does linux/Ubuntu OS creates a table, which keeps the entry of every file with
Working in Linux and using C++. I have a program which initiates a thread.
So I have an embedded Linux device that is connected to a motor controller
My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.