我想要做类似于 timeout 12s tail -f access.log | wc -l
这样的操作,但是我没有看到来自 wc
的输出。需要做些什么才能完成这个任务?
我想要做类似于 timeout 12s tail -f access.log | wc -l
这样的操作,但是我没有看到来自 wc
的输出。需要做些什么才能完成这个任务?
使用--foreground
选项和timeout
一起使用:
timeout --foreground 12s tail -f access.log | wc -l
根据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
timeout --foreground 1s
,但该命令花费的时间远远超过了1秒钟,可能是因为需要处理的数据量很大。 - Noel Yap