I'd like to know how to preform an action every hour in python. My Raspberry Pi should send me information about the temp and so on every hour. Is this possible?
I am new to python and linux, so a detailed explanation would be nice.
I'd like to know how to preform an action every hour in python. My Raspberry Pi should send me information about the temp and so on every hour. Is this possible?
I am new to python and linux, so a detailed explanation would be nice.
write a python code for having those readings from sensors in to text or csv files and send them to you or to dropbox account
and then put a cron job in linux to run that python script every hour
type in your command line
sudo su
then type
crontab -e
In opened file enter:
/ 0 * * * * /home/pi/yourscript.py
where /home/pi/yourscript.py is your fullpath to python script and it will execute this "yourscript.py" every 60 min.
To send your code to you - you have to choose some way- 1) you can send it to your inbox 2) to dropbox account 3) to sql data base In any case you have to write script for that.
you can check out the sched module (in the Python standard library).
personally, I'd keep it simpler, and just run your script every hour using a system scheduler like cron.
a basic crontab entry to run hourly (on the hour) might look like this:
0 * * * * /home/foo/myscript.py > /dev/null 2>&1
if you really want to write a scheduler in Python, see some of the answers given here: How do I get a Cron like scheduler in Python?
The easiest way would be to set up a cron job to call a python script every hour.
Use systemd. https://www.digitalocean.com/community/tutorials/what-is-systemd
You can schedule it when you want, and monitor it with journalctl