Grab some lines of `fly logs` without watching?

Context is looking to grab a quick snapshot of fly logs from CLI but without leaving the cli process streaming in the console.

Imagining a sort of non-follow/watch option for fly logs (like tail -n type thing) that could one-shot grab some lines from the latest logs and exit. Or is there some bash-fu that might accomplish that by running it and killing it after a delay/amount of input?

(Thought I had lead on a solution with | tail -n 10 or | head -n 10 but didn’t seem to work consistently - with repeated runs would sometimes continue streaming sometimes return immediately)

This worked for me:

timeout 1 fly logs > blahblah.log

timeout will kill the (otherwise long-running) command after 1 second - it’s enough to grab the most recent logs as you needed.

  • Daniel

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.