Search code examples
pythonraspberry-pischedule

How to schedule an action in python?


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.


Solution

  • 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.