We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Cron trouble



  • I'm playing with a modified script of Brad without GPS. just the OLED expansion. It retrieves weather from Weather Underground. It works very well. I'm trying to use cron and crontab to do this once an hour. Right now it's set for once a minute till I get it working. Here's what the crontab looks like.

    */1 * * * * /root/showweather.py >> /tmp/output.txt 2>&1

    Make sure you have this comment at the end of your crontab

    (There IS a hash symbol in front of "Make")

    I enabled cron with /etc/init.d/cron restart
    But, never see cron operating. If I send just this:
    /root/showweather.py from terminal, I see the update retrieved from WU on the OLED and the terminal.
    Why isn't cron showing any signs of life?



  • *     *     *   *    *        command to be executed
    -     -     -   -    -
    |     |     |   |    |
    |     |     |   |    +----- day of week (0 - 6) (Sunday=0)
    |     |     |   +------- month (1 - 12)
    |     |     +--------- day of        month (1 - 31)
    |     +----------- hour (0 - 23)
    +------------- min (0 - 59)
    

    I also keep my crontab info in a text file in /root. Whenever I make a change, or want to add to it, all I need to do is edit the text file, then run the following:

    crontab /root/crontab.txt
    

    I always then verify it is there with

    crontab -l
    

    Then, you can restart crontab with

    /etc/init.d/crontab restart
    

    For me, this is easier and allows for cut/paste.

    My crontab is set for ever 20 minutes.

    */20 * * * * /smb/scripts/phpweather.sh
    


  • @Brad-Buskey
    What do you see that is wrong?
    I tried crontab -1 got back crontab: unrecognized option: 1



  • in your crontab line, you have it set to run every minute. That is the first group.

    and it isnt -1, it is -l (lowercase L)

    Also, maybe make the command cleaner by wrapping up the /root/showweather.py >> /tmp/output.txt 2>&1 into a sh script. The system may be wanting the command to actually include a call to Python:

    python /root/showweather.py >> /tmp/output.txt 2>&1
    

    Also, bare in mind I am still a beginner at all this stuff. weird not pointing/clicking to do these kinds of tasks and I have never been a programmer. I just know what has gotten my stuff working on my unit so far, and there are probably lots of better or more efficient ways to do the same thing.



  • @Brad-Buskey
    OK on -l or list. I now know what the problem is. I chose to use nano to create the crontab. And of course it wanted to put it in /root for I didn't tell it any different. Should have paid attention: it has to be in /etc/crontabs.2380
    Thanks for waking me up.
    How's the GPS section? Don't have the board, so commented out everything relating to GPS. Was not sure you were done with it.



  • @Don-DeGregori Overall the GPS works fine. I guess I was one of the lucky ones who got a working board. It can be tempermental in finding signal sometimes, but for the most part, no issues. It will even find enough signal to work while in the house. I have the weather script on GitHub without the GPS using my own PWS (through Weather Underground). I also modified it to create a web page in the /www directory on the Omega2+ that refreshes every 20 minutes. It has been running for the last 5 days on my one stationary Omega2+ and has been flawless so far. I am going to start using GitHub as a backup spot for these things. Makes it easy to share as well.

    https://github.com/deckyon?tab=repositories



  • @Brad-Buskey
    Brad ... Bringing in all three scripts into GitHub is super! So much easier to learn from your efforts. I sure wish Onion would put a larger size OLED on the board. Seems to be plenty of room horizontally, and make the board bigger vertically. My eyes not so good anymore. I'm getting WX info every 20 minutes like you, just from WU. Think I'll add tiny push button to get it live as a demo. Using Power Dock expansion. No access to other pins except to solder right to Omega2. Bummer!



  • @Don-DeGregori Thanks for the comments.

    You might be able to do something with IFTTT and the Do Button. It is something I wanna get working with my Apple Watch.



  • @Brad-Buskey
    Could fire up a 16 x 4 LCD laying around, but that's serial. Don't need the effort right now. Think I'll find a little magnifier and mount it right above the display, LOL. More later sir .....


Log in to reply
 

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