Page 1 of 1

Problems taking photos on boot

Posted: Thu Dec 28, 2017 9:48 pm
by sbaratheon
Hi

I'm trying to take photos automatically on boot of my Pi. I've created a shell script which is essentially a timelapse (I didn't use the native version as it doesn't allow you to record the timestamp of the photo). I've tested running this script and it works fine.

To get the script to run on boot, I added it to the /etc/rc.local file. I ran the rc.local file manually and it works fine.

However, when I boot up my Pi the camera board seems to fire up (the led turns on) but no photos are recorded. I've tried adding a 60 second delay to /etc/rc.local so that the system is fully booted up but to no avail. Any ideas?

Many thanks

Re: Problems taking photos on boot

Posted: Thu Dec 28, 2017 11:18 pm
by DougieLawson
Where are you directing the output? /etc/rc.local runs with a limited environment and may not have the current working directory you expect.

Re: Problems taking photos on boot

Posted: Thu Dec 28, 2017 11:23 pm
by sbaratheon
DougieLawson wrote:
Thu Dec 28, 2017 11:18 pm
Where are you directing the output? /etc/rc.local runs with a limited environment and may not have the current working directory you expect.
rc.local runs a script in /home/pi/ which in turn outputs images to /home/pi/timelapse/

Do you think that might be the issue?

Re: Problems taking photos on boot

Posted: Thu Dec 28, 2017 11:40 pm
by DougieLawson
It runs as root. So shouldn't be writing to /home/pi unless you are using a setuid and/or setgid calls to change back from root to pi.

Try starting it from a sudo nano /etc/systemd/system/something.service file

Code: Select all

[Unit]
Description=run pi service at boot

[Service]
ExecStart=/home/pi/python/something.py
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=piservice
User=pi
Group=pi

[Install]
WantedBy=multi-user.target
Create that, then enable and start it with
sudo systemctl enable something.service
sudo systemctl start something.service

Re: Problems taking photos on boot

Posted: Fri Dec 29, 2017 12:17 am
by sbaratheon
DougieLawson wrote:
Thu Dec 28, 2017 11:40 pm
It runs as root. So shouldn't be writing to /home/pi unless you are using a setuid and/or setgid calls to change back from root to pi.

Try starting it from a sudo nano /etc/systemd/system/something.service file

Code: Select all

[Unit]
Description=run pi service at boot

[Service]
ExecStart=/home/pi/python/something.py
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=piservice
User=pi
Group=pi

[Install]
WantedBy=multi-user.target
Create that, then enable and start it with
sudo systemctl enable something.service
sudo systemctl start something.service
Hi

I did all of the above (no error messages) but the camera doesn't startup (no led) on boot. Looking at it another way, could I set my script to output images somewhere else?

Re: Problems taking photos on boot

Posted: Fri Dec 29, 2017 12:48 pm
by DougieLawson
Post the code you're running.

Re: Problems taking photos on boot

Posted: Fri Dec 29, 2017 2:30 pm
by sbaratheon
DougieLawson wrote:
Fri Dec 29, 2017 12:48 pm
Post the code you're running.
Ah, I've realised my mistake. The script referred to raspistill -o [directory] but the fully directory was not specified. I think rc.local needs the full script name (which was provided) but also the contents of that script needs to refer to the full directory.

Thanks for your help.