geerlingguy/pi-timelapse

Allow Pi to be set to start capture on boot (e.g. 100% headless/network-free)

geerlingguy opened this issue · 5 comments

I'd like to be able to set up my rig to start taking pictures immediately after it gets power; this way I could take it anywhere, set it up, then let it go (without having to have a WiFi network or some other means to log in and run the appropriate commands.

See immauss' comment on my Pi Timelapse blog post for a nice and simple implementation. Something like that seems like it would work great.

Thank you for this, I am also planning a similar feature in a current build where I will be hiking and have no network control. I plan to put some simple switches to start/stop the timelapse and will update you.

The way I've quickly done this is to install screen

sudo apt get install screen

and then invoke the script from in a 'screen'

screen -S timelapse -d -m /usr/bin/python /home/pi/pi-timelapse/timelapse.py

To run in crontab every 5 minutes, this would work:

*/5 * * * * screen -S timelapse -d -m /usr/bin/python /home/pi/pi-timelapse/timelapse.py

To run at boot, add this to the crontab

@reboot screen -S timelapse -d -m /usr/bin/python /home/pi/pi-timelapse/timelapse.py

To connect to the screen, simply execute

screen -r

I did also update the script so that it does not reference the current working directory, but rather the directory the script is located in, as this was required for crontab.
Would you like me to create a PR for this change?

@nbarry101 - Just saw the PRs, they look great (just a couple changes requested in the latest one)! Thanks for the contribution here... I'm actually going to use this tonight so my rig will start taking pictures early in the morning tomorrow for an eclipse timelapse!

I decided to use Systemd, since it's present on the latest version of Raspbian, and since a unit file gives a lot of flexibility when it comes to starting/stopping/logging/system boot enabling.