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?
1 Answer
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
1 Comment
Noel Yap
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.