Recently, I wrote a post about a screenshot application which has a basic editing tool called HotShots. The application was very handy especially if you are a new users which prefer using GUI application to do such task. There is another way to take screenshot in Ubuntu, especially for those who prefer working with shell script. Ubuntu has a command line application called scrot which allows us to take screenshot from shell script. This tool is very handy, as it's a command line application, you can integrate it in a shell script easily. In this tutorial, I'd like to show you how to take a screenshot at regular interval using scrot.


Install Scrot
Scrot is available on Ubuntu's default repository, so to install it simply execute the following command:
  • sudo apt-get install scrot
The Script

The shell script just contains four lines but it will do a cool task. It will automatically take 25 screenshots with 3 second interval. The images will be saved in PNG format and put in Pictures folder in Home directory. There are five variables which can be changed to suit your need:
  • {1..25}. It will take 25 screenshots, change the number "25" as you wish.
  • scrot -d 3. It will take a screenshot on 3 seconds interval. Simply change "3" to any number which suit your need.
  • %Y-%m-%d-%H:%M:%S.png. The pictures taken will saved in PNG format. You can change this to JPG if you want to.
  • ~/Pictures/ The files will be automatically saved in Pictures folder inside Home directory.
Once done editing, save the script with any file name you like, e.g. "scrot.sh". The script can be executed until you give an execute permission to that file. Run the following command to give the execute permission to "scrot.sh":
  • chmod +x scrot.sh
Now, you can take screenshots automatically at regular interval by running "scrot.sh" we've just created.

via: MTE