Python
solución (con argumento dinámico intervalo de tiempo ):
tailing_by_time.py
guión:
import time, sys
t_gap = int(sys.argv[1]) # time gap argument
ts = 0
while True:
line = sys.stdin.readline().strip() # get/read current line from stdin
curr_ts = time.time() # get current timestamp
if ts and curr_ts - ts >= t_gap:
print("") # print empty line/newline
ts = curr_ts
if line:
print(line) # print current line if it's not empty
Uso:
tail -f error.log | python tailing_by_time.py 3