Reader small image

You're reading from  Wearable-Tech Projects with the Raspberry Pi Zero

Product typeBook
Published inJul 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781786468819
Edition1st Edition
Languages
Right arrow
Author (1)
Jon Witts
Jon Witts
author image
Jon Witts

Jon Witts has been working within the IT industry since 2002 and specifically within Educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organisation he was then working with. Having studied Fine Arts and Educational Technology and sought to innovate with open and accessible digital technologies within his creative practice, Jon is happiest when deconstructing technology and finding its limits. Jon has embedded within his school the use of Raspberry Pi computers, as an integral part of the delivery of the school's Computer Science curriculum as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organise and run the Hull Raspberry Jam events. I would like to thank my wife, Sally and our three daughters for putting up with all the cables and compoents around the house, and not least for being so tolerant of the need to dodge the robots racing round the kitchen floor!
Read more about Jon Witts

Right arrow

Making our program run automatically

One of our last steps here is to make this Python program run automatically. First, we need to make the program we just wrote executable by typing sudo chmod +x ./gpsTracker.py. Now, will create our service definition file by typing this:

sudo nano /lib/systemd/system/gpsTracker.service

Now, type the definition into it:

[Unit]
Description=GPS Tracker Service
After=multi-user.target

[Service]
Type=idle
ExecStart=/home/pi/WearableTech/Chapter9/gpsTracker.py

[Install]
WantedBy=multi-user.target

Save and exit Nano by typing Ctrl + O, followed by Enter, and then Ctrl + X. Now reload the systemd daemon and activate our service by typing this:

sudo systemctl daemon-reload
sudo systemctl enable gpsTracker.service

As we have combined the function of our Shutdown button into this Python program, we can now also stop that service from running by typing this...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Wearable-Tech Projects with the Raspberry Pi Zero
Published in: Jul 2017Publisher: PacktISBN-13: 9781786468819

Author (1)

author image
Jon Witts

Jon Witts has been working within the IT industry since 2002 and specifically within Educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organisation he was then working with. Having studied Fine Arts and Educational Technology and sought to innovate with open and accessible digital technologies within his creative practice, Jon is happiest when deconstructing technology and finding its limits. Jon has embedded within his school the use of Raspberry Pi computers, as an integral part of the delivery of the school's Computer Science curriculum as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organise and run the Hull Raspberry Jam events. I would like to thank my wife, Sally and our three daughters for putting up with all the cables and compoents around the house, and not least for being so tolerant of the need to dodge the robots racing round the kitchen floor!
Read more about Jon Witts