sbaratheon
Posts: 81
Joined: Sun Sep 30, 2012 10:33 am

Problems taking photos on boot

Thu Dec 28, 2017 9:48 pm

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

User avatar
DougieLawson
Posts: 34166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Problems taking photos on boot

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.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

sbaratheon
Posts: 81
Joined: Sun Sep 30, 2012 10:33 am

Re: Problems taking photos on boot

Thu Dec 28, 2017 11:23 pm

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?

User avatar
DougieLawson
Posts: 34166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Problems taking photos on boot

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
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

sbaratheon
Posts: 81
Joined: Sun Sep 30, 2012 10:33 am

Re: Problems taking photos on boot

Fri Dec 29, 2017 12:17 am

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?

User avatar
DougieLawson
Posts: 34166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Problems taking photos on boot

Fri Dec 29, 2017 12:48 pm

Post the code you're running.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

sbaratheon
Posts: 81
Joined: Sun Sep 30, 2012 10:33 am

Re: Problems taking photos on boot

Fri Dec 29, 2017 2:30 pm

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.

Return to “Camera board”