Reading: None.
In this lab, you will combine the work from your previous labs to create a fully functional temperature logger. You will measure "real" data that can later be analyzed in the aggregate on a central system.
Your BeaglePlay will need Internet access for this lab.
In this part, you will configure the cron daemon to run archivist once per hour. If your BeaglePlay is connected to the Internet at that time, archivist will transfer new data to the cloud. Otherwise, if your device is not connected, archivist will do nothing.
Proceed as follows.
Start by installing the mailutils package with the command:
$ sudo apt install mailutils
This package contains comprehensive support for sending and receiving email from/to your BeaglePlay. We need it so that cron can send email to the debian user, but the package provides general support for a variety of mail protocols and scenarios.
Use the following commands to set up debian's mailbox.
$ sudo touch /var/mail/debian $ sudo chown debian /var/mail/debian $ sudo chmod 660 /var/mail/debian
Test the configuration by running the mail command. You should get the response "No mail for debian." If you get an error message, something is wrong.
Next, create a crontab file named debian.cron. It should contain the following.
# Use /bin/bash to run commands, instead of the default /bin/sh SHELL=/bin/bash # Mail any output to 'debian', no matter whose crontab this is MAILTO=debian # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # m h dom mon dow command 47 * * * * cd /home/debian/cis-2730 && ./archivst.py
Change the minutes field to an arbitrary value between 0 and 59. This will help ensure that everyone won't try to contact the cloud server at the same time.
Submit your crontab using the command crontab debian.cron. You will not see any response to this command (but also no error message). Now cron will run the archivist program once per hour and email you any output it produces (which should be nothing if the program executes successfully, even if there is no network connection).
Notice that cron is running archivist directly from your workspace. This means if you edit the program, the change will "immediately" take effect (i.e., whenever cron tries to next run it).
In this part of the lab, you will set up the observer program to run as a system service. The details on doing this can be obtained by querying a suitable LLM. For example, the following prompt is a good starting point:
I have a Python program that I would like to run as a service on my Ubuntu Linux server. How can I set up `systemd` to do that?
A traditional search can also yield good results in the forms of tutorials and forum posts. Try
searching on setting up a systemd service for a python program
. Using both traditional
searches in combination with LLM-generated summaries and reading the authoritative documentation
(e.g., manual pages), is the best approach.
Zip together debian.cron, and your systemd unit file. Submit the zip archive to Canvas.
Last Revised: 2025-03-25
© Copyright 2025 by Peter Chapin <peter.chapin@vermontstate.edu>