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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:41:06+00:00 2026-06-18T15:41:06+00:00

According to: Java IO implementation of unix/linux "tail -f" Java "tail -f" wrapper I

  • 0

According to:

Java IO implementation of unix/linux "tail -f"

Java "tail -f" wrapper

I assume its possible but I have the following problem.

String TailCommand = "tail -f /path/PATH.txt| grep (...)";
Runtime r = Runtime.getRuntime();
Process p = r.exec(TailCommand);

//handle buffer

while (running) {
    // handle output
}

Process p terminates. It works fine with commands that doesnt have constant updates unlike “top” or “tail -f”.

I wonder if I missed something, there is some buffer limitations or whatever?
Im using eclipse but i guess that should not have any impact on process behavior.

In fact maybe there is another simply way to solve my issue that i missed. Im using “tail -f” since i have to analyze quite fat(some GBs) log thats constantly appending and dont intend to open it and read the whole file. I need only to controll the appending lines. However i found no suitable tail implementation

Thanks in advance.

  • 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-18T15:41:07+00:00Added an answer on June 18, 2026 at 3:41 pm

    You can’t execute piped commands from inside java.

    If you want piped output, execute ‘/bin/sh’ like this:

    String tailCommand = "/bin/sh -c 'tail -f /path/PATH.txt| grep (...)'";
    

    Also, your java program must consume the output of the process fast enough, so its buffers do not overflow.

    You may want to read this article When Runtime.exec() won’t, for description of common pitfalls when trying to execute a process from Java.

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

Sidebar

Related Questions

I have been asked to write a java program on linux platform. According to
I am trying to configure tomcat according to Dealing with "java.lang.OutOfMemoryError: PermGen space" error
I have the following directed graph implementation Nodes nod[] List<Arcs> arc[] So the node
I am writing a network server in java, and I have a tiny problem
I have a problem with Tomcat 5.5 and Java EE webapp libraries. I'm using
My problem is I have a Java application that renders an image. Now I
A seemingly straightforward problem: I have a java.util.concurrent.Semaphore , and I want to acquire
According to this post: https://stackoverflow.com/questions/6666659/threading-implications-of-asynchronousbytechannel the java implementation of asynchronous socket channel doesn't guarantee
When using standard Java serialization, it is possible to have an object replaced on
According to Java thread state info calling wait() will result a thread to go

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.