Setting a file to run automatically on startup

If you take your Raspberry Pi Zero with you a lot, unplug it at night, or reboot often, you don't want to have to start services and programs manually every single time. Linux has a rich set of tools that control what services start up when the Raspberry Pi does.

Getting ready

We're going to make a copy of our temperature script and add a little bit to it. First, make a copy as a new script, called rpz_startup.sh. We'll use the cp command we learned in an earlier recipe:

pi@rpz14101:~/share/ch3 $ cp rpz_temp.sh rpz_start.sh

How to do it...

  1. This file will have some new variables in it, the format will be slightly different, and we will write it directly to our rpz_startup.log file in /var/log/. The

Get Raspberry Pi Zero Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.