OLED w/temp expansion project - problem running code periodically with CRON



  • I set up and ran the OLED/temperature asdescribed in the Onion project book. I can successfully run the 'python main.py' command and see the temperature value update on the OLED and to ubidots dashboard but having no success automating it to update periodically with the CRON. Following the steps in the project book and all I get is the temperature value holding from the last 'python main.py' command. Any troubleshooting suggestions?



  • @congo What is your crontab entry?
    Cron executes instructions in a separate shell with its own environment (incl PATH), so, often, programs that execute successfully in the user shell by being called by name only (e.g. python) need to have their full path specified (e.g. /usr/bin/python) in order to execute successfully in a crontab entry.
    Post output from crontab -l (lower case L) if you are able.



  • this the 'crontab -e' entry

    0_1515381758164_9a5e649b-f644-4c45-b57d-18337c84c580-image.png



  • @congo
    Ok, for that line to operate correctly, it looks like you need to insert some spaces between the "*"'s (starting after the first one) and to correct the spelling of "/user/" to "/usr/" (remove the "e").
    e.g.

    # m h dom mon dow command
    * * * * * /usr/bin/python /root/temperature-monitor/main.py
    

    [edit]
    added header line for purposes of understanding the crontab fields, where:
    m - minute
    h - hour
    dom - day of month
    mon - month
    dow - day of week
    command - command to execute
    [/edit]



  • Thanks for that! I cleaned those mistakes up and its running properly now.


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.