Using crontab to run a script automatically at predefined intervals

For the last recipe in this chapter, we will look at the popular crontab utility, a service that will execute a command or script at a regular interval of your choosing. It is a vital part of the system administrator's toolbox, and one you'll find a lot of uses for, especially when connecting to sensors and Internet of Things devices.

Getting ready

If you followed the recipe to make the Raspberry Pi Zero temperature script, you are ready to go.

How to do it...

Let's start logging the temperature of the Zero to a text file. We will take a reading every minute and save it in the /var/log/rpz_temp.log file. Over the course of a day, especially on days when you are using the Pi a lot, ...

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.