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 8199007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:04:59+00:00 2026-06-07T06:04:59+00:00

I have a log file that is going to be updated by a shell

  • 0

I have a log file that is going to be updated by a shell script. This shell script has a number of operations and updates the file after each operation, saying the operation has finished. Now, I need to ‘listen’ on this file from a servlet and send response back to the end user in the same fashion as the logging happens (i.e. operation A finished, operation B finished and so on). Now if both the servlet and the shell script try to open the file at the same time I am sure I will get some error. In java I guess I can handle it as IOException and keep trying to read the file, so that it works when the shell script is not updating the file. How should I handle this in shell script? Will it help if I open the file in read only mode in java? Also note that the shell script only writes and doesn’t read and the servlet only reads and doesn’t write.

Also, suggestions welcome on a better way of implementing this workflow.

  • 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-07T06:05:01+00:00Added an answer on June 7, 2026 at 6:05 am

    Since you can’t use the WatchService, you could poll the files last modification using file.lastModified().

    If you do this periodically, you can compare the results and if they changed, the file was modified by the shell script. It might be necessary to create a new File object everytime you poll, but since the file isn’t opened for reading at all no access problems will occur.

    However, even if you open the file and compare its contents you should not experience any access problems, unless your shell opens the file with exclusive access.

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

Sidebar

Related Questions

I have a script that runs at evening, it writes to a log file
I have a log file that I'm trying to append data to the end
I have a log file that I am reading to a string public static
I have a log file in SqlServer that stores the time an application started,
I have a log method which saves to a file that is named the
I have a transaction log file in CSV format that I want use to
I have one requirement that i have to place the log file in the
I have a command (cmd1) that greps through a log file to filter out
I have a WCF service that is responsible for writing a log file. I
I have a log file that looks like the following: 2010-05-12 12:23:45 Some sort

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.