Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I've got a process that I want to inspect with strace, but since it's printing out a lot of stuff, I would like to sample only a few lines every X seconds from it. Is there any way of doing that with bash or similar?

For example:

strace -p 123456 | "print out most recent 80 lines every 2 seconds"
share|improve this question

1 Answer 1

up vote 3 down vote accepted


strace -p $PID >$PID.log &
watch tail -n80 $PID.log >$PID-sample.log &
tail -f $PID-sample.log

or just watch tail -n$LINES $PID.log if you don't need to scroll back through the sampled log.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.