How to take a screenshot every n second?

What software can I use to take screenshots with a set interval? I'd like to take screenshots every 2 second or so. Command-line and GUI are both ok.

I'd prefer software that can also resize and compress each screenshot.


Solution 1:

Install scrot and then run this:

while true; do scrot & sleep 2; done

Solution 2:

watch -n2 scrot

or

while true; do scrot -d2; done