Raspberry Pi Time-Lapse in Four Easy Steps

In this guide, I will take you through from start to finish on how to set up your very own Raspberry Pi time-lapse setup.

raspberry pi time lapse

We make use of the Raspberry Pi camera in this guide. You’re able to pick this cool camera at any good electronic store that sells the Raspberry Pi.

I will take you through everything you need to know to get it all set up and ready to go. The process is pretty easy, and you will learn how to set up cron jobs and more.

This tutorial is also an excellent way to learn more about the Raspberry Pi camera and the things that you can do with it. The time lapse that you end up producing is pretty cool and so easy to set up.


The equipment you will need in this tutorial is listed below.

Raspberry Pi

Raspberry Pi Camera

Power Supply

Micro SD Card



Video on setting up the Time-Lapse Machine

If you’re not much of a reading person then check out the excellent video on how to do the Raspberry Pi time-lapse, I have made it just for you.

It goes through step by step everything you need to do to get your Pi taking photos, so you’re able to use these in a time-lapse video.

Adblock blocking the video? Support us by subscribing to our ad-free service.

Installing the Camera

Probably the most important step is to connect the Raspberry Pi camera correctly to your Pi.

This process is pretty straightforward, but for anyone new to this kind of stuff will find this section helpful.


To install the camera, you will need to go to the ribbon cable attachment and press gently with two fingers on either side of the connector and pull up.

This technique will open the attachment, now insert the cable with the metal leads facing away from Ethernet port.

Once lined up and the cable is inserted far enough, gently press the connector back down, and the cable will now be locked in place.



To start this Raspberry Pi time lapse project you will need a copy of Raspbian installed. If you had followed my guide on installing NOOBS, you would have turned on the Raspberry Pi camera functionality.

If you haven’t, then you can turn it on by going into the terminal and writing the following line.

sudo raspi-config

After this select enable camera and select yes. You will then need to reboot the Raspberry Pi.

Testing the Camera

1. If your Pi is off now is the time to turn it on.

2. Go to the terminal screen and enter the following command.

raspistill -o cam.jpg

3. If you now type ls you will be able to see the image file now exists(cam.jpg). Open this image in the file browser or from your machine if you are using SSH.

If you are new to Linux, then you may find the guide on the ls command helpful.

4. If the image is upside down, then your camera is not positioned the correct way. You can either fix the camera up or just simply flip the image by using the following command.

raspistill -hf -vf -o cam2.jpg

5. You can now confirm that the image is now facing up the correct position.

Write a Script

It is now time to write a script that will take a picture and stamp the file name with the date and time.

If you would prefer not to write a script, then you can download the script I have already made here camera.sh. Alternatively, you can download it directly to the Raspberry Pi.

sudo wget https://files.pimylifeup.com/timelapse/camera.sh

The script is straightforward, but remember, you will need to add -hf -vf flags if your camera is currently upside down.

Make the directory and call it timelapse by entering the following command.

mkdir timelapse

Move into this folder by entering the command below.

cd ./timelapse

Now we need to create a bash script called camera.sh using a text editor such as nano. You can do this by entering the following.

sudo nano camera.sh

In this file, copy and paste the bash script below.

DATE=$(date +"%Y-%m-%d_%H%M")
raspistill -o /home/pi/timelapse/$DATE.jpg

Test the script by running the following line.

sh camera.sh

If it fails to run, look at the error message and try to debug the code. Also, try cross-checking with my code above.

If it doesn’t fail, then we are onto the next stage, setting up a schedule for the Pi to run.

Schedule the Script to take Pictures

The script above is now complete, and while you can make further adjustments to it, we will keep it basic for this guide.

Next, we will need to schedule the script to run so we can run this over x amount of time, allowing us to capture hundreds or thousands worth of pictures.

Let’s open the crontab for editing by entering the following.

sudo crontab –e

If you have never used cron, it will prompt you to select a text editor. I recommend choosing nano as I find this the easiest to quickly learn.

Once in, scroll down to the bottom where you will find some helpful column headers that look like below. These are your guide for setting a cron job.

Check out our tutorial on cron jobs to learn more about how the cron system works. Perfect if you’re just starting out and would love to learn more.

# m h dom mon dow   command

To schedule the time-lapse to go off every minute, add the following line. You can change this to whatever you would prefer.

* * * * * sh /home/pi/timelapse/camera.sh 2>&1

Once done, exit and save (ctrl x and press y and enter to save).

You should then get the following message.

crontab: installing new crontab

If you type in watch ls in our new timelapse folder, it should now start to fill up with images you can use in making a time-lapse.

You’re able to shut down and move this to wherever you would like, and it will start retaking photos when you reboot the Pi.

If you ever need to edit or remove the cron job follow the same steps and edit or delete the line that we added.

Now, this method just saves the pictures directly to the Pi, and you can set it up to save to a USB stick, network drive and other places to store data.

To get your data off the Pi simply insert a USB into the Raspberry Pi and using the GUI (Graphical User Interface) copy and paste the files onto the USB stick.

If you want to make a time-lapse out of your images, take a look at my guide 5 Easy Steps To Turn Time Lapse Images To Video.

Deploying your Raspberry Pi Time-Lapse

One of the most amazing things about the Pi is how portable and energy-efficient it is. If you have a battery pack, you will be able to run the Pi for a few hours, and the best thing is you can place it anywhere you would like.

Once you have done setting up the Raspberry Pi camera and the cron job, you can just disconnect and place anywhere you would like. You don’t need to have a screen connected to the Pi for it to work.

There you have it, your very own Raspberry Pi time-lapse that you’re able to take some pretty awesome photos now and then transform it into a fantastic time-lapse.


  1. Avatar for Qhaliff
    Qhaliff on

    Hi, I want to capture a still image every 3 hours and I have inputted the code

    * */3 * * * sh /home/pi/timelapse/camera.sh 2>&1

    The raspberry decided to take a picture once three hours later and then, it took a bunch of photos that I think are at a one minute interval. How can I solve this out?

    1. Avatar for Luka
      Luka on

      Qhaliff try this:
      0 */3 * * * sh /home/pi/timelapse/camera.sh 2>&1

  2. Avatar for Jason
    Jason on


    Thanks for the super quick response, I guess the best time to post here in the UK is early morning.

    That worked, in as much as I no longer get the error not found. However, it now says

    Every 2.0s: 1s

    but there are no images within the ‘timelapse’ folder to ‘play’ with, any idea’s?

    Thanks once again.

    1. Avatar for Gus
      Gus on

      Every 2.0s ls is the correct output (Should be in the header). It means it’s running ls every 2 seconds.

      Have you tested the camera to make sure it’s taking pictures ?

      Try running raspistill -o /home/pi/timelapse/test.jpg and see if it throws an error or outputs a picture.

    2. Avatar for Jason
      Jason on

      Thanks I got it working. Just one thing, is it possible to schedule the time lose to start/stop at a particular time as I want to record the sunrise/set. I’m not asking for the code as I want to research and learn this myself, however a simple yes or no and maybe a nudge in the right direction would be helpful.

      Thanks again.

  3. Avatar for Jason
    Jason on


    I’m very new to this community and having fun learning.

    However, I’ve followed your instructions to the letter, but when I type the ‘watch 1s’ command I get the following:-

    Every 2.0s: 1s

    sh: 1: 1s: not found

    I have no idea what this means, or how to go about correcting it, any help from anyone would be greatly appreciated.

    1. Avatar for Gus
      Gus on

      Hi Jason,

      I believe it should be ‘watch ls’ not ‘watch 1s’

      I hope that helps!

  4. Avatar for Cory
    Cory on

    I followed your tutorial and I am trying to get my photos from the pi to a USB. I have everything setup but I can’t seem to copy the pictures created with your script to the USB. Every other file on my pi seems to copy fine but the ones I made with this script insist on me renaming them first.

    There is a space at the end of the file name for each jpeg created. I’m not sure if that is the issue but I noticed it and couldn’t figure out why it was there. Any help would be appreciated.

    1. Avatar for ahmo
      ahmo on

      I’m having the same problem. When I try to cut and/or copy the jpegs to a USB flash drive, I get a dialog box saying the file already exists. There is a space, or possibly a carriage return, at the end of the file name and in front of the file extension (.jpg) for each jpeg created.

      I say possibly cuz when i list the files in the file manager, the file extension (.jpg) displays on the line below the filename.

      I am using the “camera.sh” script I downloaded from this site.

      Any thought on why this is occurring? Thanks

    2. Avatar for Ahmo
      Ahmo on

      I may have found the problem. The copy of “camera.sh” I used had a carriage return at the end of each line. I used “dos2unix” to remove the CR’s, and then I got normal filenames.

  5. Avatar for Steve
    Steve on

    And thanks for all the info. very interesting. Would it be possible to save to a diffrent location rather than having all the images save to the SD card. Mybe to somewhere like Mircosoft Onedrive via wifi from the Pi. Would this be possible. ?

  6. Avatar for Lidia
    Lidia on

    Hello, your script is a blessing, everything works 😀
    Could you please help me out though, I would like my camera to take pictures every 6 hours, what should I change?
    Thank you very much

    1. Avatar for Gus
      Gus on

      Hi Lidia,

      The following line should take a photo every 6 hours starting at midnight.

      For example Midnight = 0, 6am = 6, 12 = Midday, 18 = 6pm.

      * 0,6,12,18 * * * sh /home/pi/timelapse/camera.sh 2>&1

      or you can do it like this

      This will take a photo every 6 hours from when the cron starts up.

      * */6 * * * sh /home/pi/timelapse/camera.sh 2>&1

      Hope that helps!

    2. Avatar for Lidia
      Lidia on

      Yes, thanks so much! You really helped me out 😀
      Have a nice day :))

  7. Avatar for Tony Roof
    Tony Roof on

    I can’t get the camera to take at 10 min, I have tried
    */10 * * * sh /home/pi/timelapse/camera.sh 2>&1
    10 * * * sh /home/pi/timelapse/camera.sh 2>&1
    What do I try next? Camera does fine on the 1 minute setting in this tutorial.
    Thanks for the help

    1. Avatar for Gus
      Gus on

      Hi Tony,
      There is only 4 stars before the command but there should be 5. (Minute, hour, day, month, week)
      See if this works and let me know if you’re still having problems!
      */10 * * * * sh /home/pi/timelapse/camera.sh 2>&1

    2. Avatar for Tony Roof
      Tony Roof on

      awesome that worked, must had something out of place or like you said missing *
      got it put together and sitting in the wife’s gardening box, running on batteries.

  8. Avatar for Joshua
    Joshua on

    Is this different for the Raspberry Pi 3? I tried but nothing I did worked. Is there a new update to either the Pi or raspbian?

    1. Avatar for Gus
      Gus on

      Hi Joshua,

      I am unaware of any changes that would have broken this tutorial. I will need to take a look into it.

      Did you get any errors?

  9. Avatar for Jenny
    Jenny on

    This was very helpful can i send the photo each time it is taken to an email address? I want to leave the Pi outside and see the photos when i log onto email.

  10. Avatar for Ax3l91
    Ax3l91 on

    I think there is a mistake in your tutorial, if you follow it, the script file is in “timelapse” folder. eg: >> * * * * /home/pi/timelapsecamera.sh 2>&1


    1. Avatar for Gus
      Gus on

      Hey Ax3l91,

      I fixed this a while ago but forgot to say thanks for noticing the mistake! 🙂

  11. Avatar for John
    John on

    is there a way to send the photo after each picture is taken to a FTP or via email

  12. Avatar for Zack
    Zack on

    Raspistill can do timelapse on it’s own without needing to use crontab.

    raspistill -vf -hf -w 1280 -h 720 -o time_%04d.jpg -tl 18000 -t 1080000
    -vf is vertical flip since my camera is upside down
    -hf – horizontal flip since the image is mirrored
    -w – width. The native resolution is quite high so I just capture at 720p resolution
    -h – height
    -o Output file name and location. %04d tells it to use a 4 digit incremental number to name the files
    -tl – duration between images. If this is low, say under 2 seconds you may want to use -bm for burst mode. This keeps the camera active and you’ll have fewer dropped frames
    -t – total capture time. These are both in milliseconds so in the above example I was taking an image every 18 seconds for 3 hours which gives me 600 images and at 10 frames/second that is a 1 minute video.

  13. Avatar for liam
    liam on

    How could i change this so it takes a picture every lets say 10 seconds?

    1. Avatar for Gus
      Gus on

      Hi Liam,

      The minimum amount of time for a crontab is 1 minute. The alternative would be to create a Python script or similar to take a photo every 10 seconds.

    2. Avatar for Tony
      Tony on

      Can you use this up to the max frame rate of the camera? I want to take frames at short but varying intervals as determined by external physical occurrences.

  14. Avatar for Rich
    Rich on

    Hi, I’m trying to do a timelapse of a house build and want to run it off a battery pack. I don’t want to be there everyday so need the battery to last for 1 week. Is there a way to shut down the pi after taking a photo, wait 10 minutes, reboot, take another photo etc?
    thanks for your help.

    1. Avatar for Brian
      Brian on

      Rich – I’ve been researching this also. There are a lot of details to running off of batteries. You could use a ‘”watchdog timer’ ckt, and you’d most likely need a ‘soft power down’ circuit that checks battery voltage and sends a low power signal to the pi for a shutdown. Then again, you may want a solar panel to keep your battery charged also.

  15. Avatar for Kevin
    Kevin on

    I was wondering, if I only wanted this to take pictures during a set period of ‘hours’ a day say 6am – 9pm, what type of adjustment would be necessary?

    is that possible.

    Thanks. Great and quick guide to getting this setup.

    1. Avatar for Gus
      Gus on

      Hi Kevin,

      This is certainly possible!

      The following line will run every 5 minutes between 6am and 9pm. (If you don’t want to run every 5 minutes remove the /5 and it will run every minute)

      */5 06-21 * * * /home/pi/camera.sh 2>&1

      If you haven’t already you will need to make sure your timezone on the Pi is correct as well otherwise it will run incorrectly. This can be set in the raspi-config tool

      Hope that helps!

  16. Avatar for Robert
    Robert on

    Hello, thank you for this great explanation. Is it possible to make a picture every second or 10 sek. or 30 sek.? This would be great.
    Thank you.

    1. Avatar for VL
      VL on

      As I understand, Crontab only allowed shortest interval at 1 minutes. For interval shorter than that, perhaps a Python script could help?

  17. Avatar for Pat
    Pat on

    How could you take snaps more often than 1 minute intervals? If I want a 30sec video over 1 hr at 25fps then I need a capture every 5secs.

  18. Avatar for tristan
    tristan on

    is it possible to do this with a webcam if it is is my crontab wrong
    1 * * * * sh/media/FA90-79AA/piwebcam/timelaps.sh 2>&1
    the timelaps.sh works is it the diferent location i want to save the file in

  19. Avatar for Edgar
    Edgar on

    How can i change the time between the images. In your example it takes a picture every minute. I want to change this to 10 minutes or 30 minutes. Must i change a * to a number for example 10 ?

    Hope that you can help me out.

    1. Avatar for Gus
      Gus on

      Hi Edgar,

      Below is the typical layout for crontab scheduling.

      # minute | hour | day of the month | month | day of the week | command

      If we wanted this to run every 10 minutes we would change the minute value to 10 so it would be.

      */10 * * * * * sh /home/pi/camera.sh 2>&1

      This would be every 10 minutes of every hour, every day, every month run this script.

      Please let me know if you need more information!

    2. Avatar for Edgar
      Edgar on

      He Gus,

      Thanks for the reply. Today i made a test run and it works perfectly. i made a mistake. I want to have a picture every 5 minutes but now i have a picture every hour on 07.05, 08.05, 09,05 🙂

      So i made a change to
      0,5,10,15,20,25,30,35, etc..

      I also added a ncftput after the run to ftp backup the pictures to my nas.

      Thanks for you tutorial and fast reply!!!

    3. Avatar for Luke
      Luke on

      I tried to schedule my Pi to take pictures every 10 minutes with the following:

      10 * * * * * sh /home/pi/camera.sh 2>&1

      However it did not work???

      When I changed it to the following everything worked:

      */10 * * * * * sh /home/pi/camera.sh 2>&1

      I have seen it on the web both ways and would think the first command should work fine.

      Why do you Have to you the */10 to get it to work?

      Thank you,


  20. Avatar for Graham Tanner
    Graham Tanner on

    What does the “2>&1” part mean at the end of the crontab text – needs a bit more explanation.

    1. Avatar for Gus
      Gus on

      Hi Graham,

      2>&1 will prevent the crontab from sending an email. To do this we redirect 2 (stderr) to 1 (stdout). Since all the output is redirected to a file it will not generate an email of the output.

      In summary:
      > Means Redirection
      2 is the descriptor for stderr (Standard Error)
      1 is the descriptor for stdout (Standard Out)
      & is the symbol for a file descriptor (If you don’t have it the 1 would be considered a filename)
      For more information check out: http://unix.stackexchange.com/questions/163352/what-does-dev-null-21-mean-in-this-article-of-crontab-basics

Leave a Reply

Your email address will not be published. Required fields are marked *