During my work, I often try out tools of different complexity and develop usage and integration scenarios.

I use Ubuntu 18.04 LTS.

Sometimes if things get really complicated, I am not always sure how exactly I got to the solution, and for documentation and knowledge sharing purposes I spend additional time to become more aware of a neat and clean way with less messing around, take screenshots and so on.

Then I thought it would be great to have a screen capturing tool to take a picture say every 30 seconds silently in background so that I can:

  • Easily recap my steps and also gotchas
  • If I am lucky, directly use screenshots from this image archive for the documentation.

I thought I would, for example, configure a cronjob for shutter, but while I am already using it, there is an error "you have already shutter instance running". I will try now with scrot.

Any better ideas?

UPDATE: For the Cron managed execution, as this tool can't resolve time intervals less than one minute, here a solution (on of less rated answers in the thread) for every 30 seconds.

* * * * * /bin/bash -l -c "/path/to/executable; sleep 30 ; /path/to/executable"
  • What is your Ubuntu version? – UnKNOWn Oct 12 '18 at 6:27
  • @PRATAP 18.04 LTS – J. Doe Oct 12 '18 at 6:42
  • 4
    Kind of off-topic but I would instead recommend getting into the habit of note-taking. It's not that difficult to compose and continually update your own "documentation", and it'll be a lot easier to refer to and understand than a series of 20,000 desktop screenshots. Record what you learn, as you learn it. – Lightness Races in Orbit Oct 12 '18 at 11:33
  • sometimes if I notice an insight I do note it! still, sometimes it is just trying to find something out and many things are not worth to note. - many small steps in different directions. Notes on that would convert my workplace into a scientific Ubuntu OS experimentation lab :-) – J. Doe Oct 12 '18 at 11:36
  • 2
    Not exactly an answer to your question but why not to use some tool to record everything that happens on the screen rather than making screenshots on a 30s interval? The drawback of having screenshots only is that you might actually miss an important, problem causing step that lasts less than 30s. It might even be difficult to reproduce the full steps stack with such screenshots. The drawback of recording everything is the size of resultant movie. But you may discard it rather than saving if everything went fine. – Ister Oct 12 '18 at 12:23

I have just started learning Ubuntu.
I don't know this method is proper or not.
I Could achieve it in the below way.

I have created a script like this named ScreenShot.sh in the folder /usr/local/bin


# NAME: ScreenShot.sh
# PATH: /usr/local/bin
# DESC: Take Screenshots at every specified intervals with "watch -n 10 ScreenShot.sh" Command
# DATE: Oct 12th 2018

sudo gnome-screenshot -d 0

sudo chmod a+x /usr/local/bin/ScreenShot.sh

when i start the system and wanted to start the screen capture at every 10secs,

i run this command

sudo watch -n 10 ScreenShot.sh

i have configured my default folder, image type to be saved, with dconf editor in gnome-screenshot section.

enter image description here

enter image description here

enter image description here

Sounds are stopped by dconf settings under sound section

enter image description here


I do the same thing. This is the script that I wrote, called screenlog-capture:

#! /bin/bash
window_name() {
  xwininfo -id "$1" | \
    grep "^xwininfo: Window id" | \
    LC_CTYPE=C LC_COLLATE=C sed  's/^[^"]*"\(.*\)"$/\1/' | \

window_class() {
  xprop -id "$1" | grep "^WM_CLASS(STRING)" | cut -d '"' -f 4
  # Or we could use _NET_WM_PID(CARDINAL) -> process name

if [ ! -d "$RAMTMP" ]
  echo "RAMTMP needs to be set."
  exit 1
if [ ! -e /usr/bin/puzzle-diff ]
    echo 'Error: puzzle-diff not installed!'
    exit 1

if [ ! -w "$rootdir" ]
  echo 'Error: screenlog dir not writable'
  exit 1
if [[ $(qdbus org.cinnamon.ScreenSaver /org/cinnamon/ScreenSaver org.cinnamon.ScreenSaver.GetActive) == true ]]
du=$(df -Plh "$rootdir" | sed -n -e '2s/.* \([0-9]\+\)% .*/\1/' -e '2p')
if [ "$du" -ge 98 ]
win_id=$(xprop -root | grep "^_NET_ACTIVE_WINDOW(WINDOW)" | cut -d ' ' -f 5)
win_name=$(window_name "$win_id")
parent_id=$(xprop -id "$win_id" | grep "^WM_TRANSIENT_FOR(WINDOW)" | cut -d ' ' -f 5)
if [ "$parent_id" ]
  win_class=$(window_class "$parent_id")
  win_class=$(window_class "$win_id")
case "$win_class" in
  # Firefox-bin is full-screen YouTube video (for example)
case "$win_name" in
  *'Internet Bank'*|*'YouTube'*|MPlayer|Netflix*|Prime\ Video*)

scrot -buq 0 "$tmpfilename"
if [ ! -s "$tmpfilename" ]
if [ $(stat -c %s "$tmpfilename") -lt 500000 ]
  mogrify -depth 3 "$tmpfilename"
  mogrify -type Grayscale -depth 3 "$tmpfilename"
puzzle-diff -c -e -E 0.1 "$latest" "$tmpfilename" &>/dev/null
if [ $? -eq 10 ]
  # No relevant changes, don't keep screenshot
  rm "$tmpfilename"
  win_name="$(printf %.30s $win_class) - $(printf %.60s $win_name)"
  date=$(date '+%Y-%m/%Y-%m-%d')
  mkdir -p "$dirname"
  filename="$dirname/$(date '+%H.%M.%S') $win_name.png"
  mv "$tmpfilename" "$filename"
  rm -f "$latest"
  ln -s "$filename" "$latest"

Some of the interesting features:

  • It uses scrot to take screenshots.
  • It includes the name of the current window in the filename, making lookup easier.
  • It does not run if the screensaver is running (this is Cinnamon-specific, other desktops will need a different command to check for the screensaver state).
  • It filters out some applications I don't want to take screenshots of, this list can be easily extended.
  • It stops taking screenshots if disk usage goes above 98%.
  • It uses puzzle-diff to skip saving a screenshot if it would be the same as the previous one (with some tolerance).
  • It radically reduces the color depth of the screenshots (or even makes them grayscale, depending on the size) to save disk space.
  • I use a RAM disk for intermediate storage (before deciding whether to keep an image), but you can use the regular /tmp location as well.

I use another shell script, screenlog, to call this one periodically:

#! /bin/bash
while true
  sleep 5
  • 1
    This is a very nice script! I did something close to it, and threw the result at tesseract to enable search, and a fuzzy search that I forgot the name. It worked well for a week but my disk died before the backup had time to run, and I forgot about it. Time to do it again. – ThoriumBR Oct 12 '18 at 14:32
  • 1
    +1, full of useful tricks :) – DK Bose Oct 12 '18 at 16:30
  • @ThoriumBR I also wanted to run some kind of OCR on the screenshots, but they were all too slow for that. – Zoltan Oct 12 '18 at 17:45
  • 1
    If you run OCR every 5 seconds, all your computer will do is OCR. But if you do it every minute or two, is not that bad. Just nice -n 19 ionice -c 3 tesseract ... and you will run tesseract on low CPU and IO priorities, and not even see any slowdown. – ThoriumBR Oct 12 '18 at 19:48
  • Actually nice could be a useful addition to my script too (although I never experienced any performance impact without it either). – Zoltan Oct 12 '18 at 21:21

I came up with

#! /usr/bin/env bash


while true; do

scrot $HOME/Pictures/"$(date +%Y%m%d%H%M%S)".png

sleep ${sleep_period}

I have ~/bin and so I saved this script there as continuous-scrot.sh and made it executable. To run it, I open a terminal window and type the name of the script and press Enter. I leave this terminal window active and full-screen screenshots are captured every 30s in your ~/Pictures folder. To stop, just go back to this terminal window and press Ctrl+C.


Since I have many linux distributions where I need screenshots, and they use various window managers I use probably the oldest of screenshot utilities xwd. It is a part of XServer distribution, so I can be sure it is installed every time. I am not sure if it is distributed and if it works with wayland. The command

xwd -display :0.0 -root -out screenshot.xwd

should make a screenshot of root window of display :0.0. The output file is a special formatted dump file. ImageMagick can convert that file to some more common format. For more information: https://linux.die.net/man/1/xwd.

You can find many ideas how to run such utility on regular intervals in other answers. To make output to a different file every time you could do:

xwd -display :0.0 -root -out "$(date).xwd"

The first thing I can think about is to open a terminal and use it to issue scrot within a while with a sleep. Something like this:

while sleep 30; do scrot <whatever>; done

To me, there's a catch in this. What if you make something significant between the 30 secs interval? Have you considered a screen recorder (SimpleScreenRecorder is one available on ubuntu distribution. another name I recall is Istanbul)

  • I need the screenshots to recap in general what I do as primary purpose; screencam video is than too much though sure it would record everything. – J. Doe Oct 12 '18 at 10:45

I'd use recordmydesktop, possibly with a low fps rate and no audio to reduce the amount of data recorded.

While these are not exactly screenshots, but a full video, the advantage is that you get good compression as only differences between consecutive images need to be saved, you have the option of also recording your microphone so you can take notes by speaking, and you can optionally add start/stop buttons to the system notification area.


How I solved this for myself:

First, install the following cronjob:

* * * * * DISPLAY=:0 /usr/bin/sudo -i -u <USER> bash -c '/home/<USER>/bin/create-screenshot.sh; sleep 30; /home/<USER>/bin/create-screenshot.sh;'

Notice the DISPLAY=:0 statement to allow cron to access the X Server.

Then, create ~/bin/create-screenshot.sh with the following contents:


folder="$(date +%Y%m%d)"
y="$(date +%Y)"
m="$(date +%m)"

mkdir -p "/home/$user/screenshots/$y/$m/$folder"
file="$(date +%Y%m%d%H%M%S)".png
scrot $path
  • 1
    One possible drawback of the cron route is that you'll get screenshots taken all the time you're logged in and not only when you want. – DK Bose Oct 12 '18 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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