weisia
Posts: 8
Joined: Tue Sep 08, 2015 7:11 am

crontab not working with raspistill and timelapse

Sun Mar 04, 2018 9:50 am

I am trying to get my pi (zero) make some timelapse photo's at set times. I am using a fresh install of Stretch-lite and the instructions for using raspistill and cron from this site ( https://www.raspberrypi.org/documentati ... melapse.md and https://www.raspberrypi.org/documentati ... melapse.md )

I have made the timelapse.sh executable with chmod +x and tested it: the script works fine, but I can't get the script working using crontab. Crontab is running, the camera is connected and the script generates the correct output. Can anyone help me?

The timelpase.sh:

Code: Select all

#!/bin/bash
# script for creating a timelapse video with rapistill and store it in /home/pi$
# START AND END TIME ARE PUT IN CRONTAB
# the webpages used as sourced for information are listed at the end of this fi$
DATE=$(date +"%Y-%m-%d_%H:%:M:%S")
sudo raspistill -o /home/pi/picam/$DATE.jpg 
part of crontab:

Code: Select all

# sunrise: at every minute past every hour from 5 through 8
# sunset: at every minute past every hour from  18 through 21
* 5-8 * * * /home/pi/timelapse.sh 2>&1
* 18-21 * * * /home/pi/timelapse.sh 2>&1

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: crontab not working with raspistill and timelapse

Sun Mar 04, 2018 12:54 pm

Try running your scripts like this and then look at the file log.txt to see if there are any errors

Code: Select all

# sunrise: at every minute past every hour from 5 through 8
# sunset: at every minute past every hour from  18 through 21
* 5-8 * * * /home/pi/timelapse.sh >> /home/pi/log.txt 2>&1
* 18-21 * * * /home/pi/timelapse.sh >> /home/pi/log.txt 2>&1
dont forget cron runs in a different environment than the command line you need to include full paths to any files or programs called.
Last edited by pcmanbob on Sun Mar 04, 2018 5:13 pm, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

weisia
Posts: 8
Joined: Tue Sep 08, 2015 7:11 am

Re: crontab not working with raspistill and timelapse

Sun Mar 04, 2018 4:41 pm

Solved! Thank you very much! The log file pointed me to the error: a typo in the DATE format.

Return to “Troubleshooting”