7

I'd like to do something like timeout 12s tail -f access.log | wc -l but I'm not seeing the output from wc. What needs to be done to be able to do this?

0

1 Answer 1

5

Use --foreground option with timeout:

timeout --foreground 12s tail -f access.log | wc -l

As per man timeout:

--foreground   when not running timeout directly from a shell prompt,
               allow COMMAND to read from the TTY and get TTY signals;
               in this mode, children of COMMAND will not be timed out
Sign up to request clarification or add additional context in comments.

1 Comment

Be sure to wait long enough when initially trying this out. For example, I had first started using timeout --foreground 1s but the command took much longer than 1 second to return presumably because of the large volume that needed to be processed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.