The Crontab is the way we control what programs we want to run in the background.
Here is a link on how it works: Crontab.guru – The cron schedule expression editor
We are going to add the following lines to the crontab:
-
*/3 * * * * python /home/aranet/getAranetData.py (MAC address) > /home/aranet/aranet.txt */1 * * * * python /aranet/coPng.py > /home/aranet/coPng.log 1 1 * * * python /home/aranet/clean_data_folder.py > /home/pi/clean.log
You now will need to use the Linux editor nano or vi. nano is more user friendly
in the /home/aranet directory type crontab -e (this will only come up the first time you run crontab -e)
you will see:
Select an editor. To change later, run ‘select-editor’.
1. /bin/nano <—- easiest
2. /usr/bin/vim.tiny
3. /bin/ed
if using nano type 1
You now will see
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time, you can provide concrete values for
# minute (m), hour (h), day of the month (dom), month (mon),
# and day of the week (dow) or use ‘*’ in these fields (for ‘any’).
#
# Notice that tasks will be started based on the cron’s system
# daemon’s notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information, see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
Now just add the above to the bottom of the file:
now save the file
to verify that all is well-run crontab -l (that is a little L, which stands for a list, a -e stans for edit)
notice the 1 1 * * * in the last line. That means it will run every day, 1 minute after 1 AM.
The others will run every minute. if you want to run every 2 minutes, then It would be */2 * * * *
Next, display data via a web page