Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need a way to refresh a certain webpage and have a screenshot taken approximately every 5 minutes. I'm new with Ubuntu, but willing to use terminal, etc. If steps are given, I've used it before, I just don't know how to go about writing my own scripts.

Ideally, I would have the webpage open, and the page would refresh and take a screenshot every 5 minutes. Any help with this?

share|improve this question
1  
This is possibly a duplicate - if it is I'll merge the questions - can you confirm? askubuntu.com/questions/50958 –  fossfreedom May 23 '12 at 7:57
add comment

3 Answers

The screenshot app 'shutter' has what you are looking for.

In a terminal, do sudo apt-get install shutter

There is no GUI way to do this every five minutes with shutter, but we can make it do the job with the command line.

Copy the following into gedit:

 #! /bin/bash
 while true; do
     shutter --web='WWW-HERE' -e
     sleep 5m
 done

Replace WWW-HERE with the address you would like to screenshot. Now save it in your home folder with a name that you can remember and wish to call it with.

Open a terminal and do chmod +x FILE and then sudo cp FILE /usr/local/bin Remembering to replace FILE with the name you chose.

Now you can open a terminal and type the file name you chose to start it taking screen shots every five minutes. To stop it, press Ctrl + C on your keyboard. If you want it to keep going until you logout, you can just type the name you chose after pressing Alt + F2, and it will keep going forever in the background.

To save the files somewhere else or with a special name you can add the --output flag to the shutter command(before the -e!). So change that line to read something like this for example:

shutter --web='WWW-HERE' --output='~/Shots/Web%Y%m%d%T' -e

This saves to folder called Shots (must exist!) in your home folder, and names the file given the time and date.

Alternately you can open shutter and navigate to Edit > Preferences and select a directory there where you would like to save.

enter image description here

An example screenshot of today's google doodle is here.

share|improve this answer
add comment

Note: I haven't tried this but you could use something like scrot (to take the screenshot) and an "at" command to do the the trick. Here's two resources that might be helpful:

Screenshots from the terminal: http://tips.webdesign10.com/how-to-take-a-screenshot-with-ubuntu-linux

Using the "at" command: http://www.ibm.com/developerworks/linux/library/l-job-scheduling/index.html

share|improve this answer
add comment

I once had a script to take a photo of my screen every minute and upload it. I've tried to create something similar for you here. As Mordoc mentioned, you can use scrot Install scrot. You will have to sudo apt-get install scrot first.

Here's the script. The lines starting with "#" are comments, so I'll use them to try and explain it:

#!/bin/bash
# ^This first line just tells linux which script language to use.
#  We're using bash

# Because this script runs as a Cron-job, it runs as root and doesn't
# necessarily know which user you're logged in as.  For me, this says "use
# the default display, ie the first person logged in on the computer"
DISPLAY=:0
HOME=/home/vose
export DISPLAY
export HOME

# Create the screenshots directory in case it doesn't exist yet
mkdir -p /home/vose/Pictures/Screenshots/

# Delete any screenshots more than 7 days old.
find /home/vose/Pictures/Screenshots/ -type f -mtime +7 -delete

# Launch the browser (I use firefox for normal, so I'll use chrome for this)
# The "sudo -u vose ..." means "run the command as user `vose`".  You'll
# You'll need to put your username in there...
# The "&" at the end means 'launch in the background', so the script
# can keep going.
echo "Opening the browser"
sudo -u vose chromium-browser http://google.com &

# This records the ProcessID (pid) of the last opened program
# (chromium) so we can kill it later
pid=$!

# Wait 10 seconds for the browser to open and page to load
# On a slow computer/connection/webpage you may need to wait longer
sleep 10

# Take the screenshot using scrot.  Save it to this file
scrot /home/vose/Pictures/Screenshots/screenshot_`date +%F-%H-%M-%S`.jpg
echo "Created screenshot_`date +%F-%H-%M-%S`.jpg"

# Kill the browser
kill $pid

Before you try go too far, stop and see if this works.

  1. First, save the script above as takeScreenshot.sh.

  2. Then from a terminal, type chmod +x takeScreenshot.sh (Chmod changes the permissions on a file, and '+x' means we're giving it permission to "execute" the script.)

  3. Run ./takeScreenshot.sh from a command line - this will run the script manually. See if the file shows up in your pictures folder after doing this.

  4. If that worked, we need to now add it to Cron.

At a command line, type sudo crontab -e. (If it asks you which editor, choose Nano. If you haven't used it before, ask around for some help).

In the file, you want to add a line at the bottom, like this:

# m h  dom mon dow   command
*/5 * * * * /home/vose/Scripts/takeScreenshot.sh

What this says:

  • Every 5 minutes
  • Every hour, every day-of-month, every month, every day-of-week
  • Run "/home/vose/Scripts/takeScreenshot.sh"

(one small gotcha: make sure there is a blank line after your entry in the crontab. The last line of the file gets ignored, so you need a blank line after your command).

Well, I hope this long post helps! There might be ways to do this without the command line, but you'll have to look around.

share|improve this answer
add comment

Your Answer

 
discard

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.