Forum Discussion

sundogbrew's avatar
sundogbrew
Icon for Altocumulus rankAltocumulus
Feb 17, 2018

Strange question Cron problems

So I have this strange problem. I have been having trouble with one of my F5s that is in a remote location. I wrote a quick script to check temp and email if it is high. So if I run it command line it works fine. Basically it checks, emails me and next time it runs it checks to see if there are any new temp alerts. So it works fine if I just run the script. But I am having trouble with it running as a cron job? If I run mailx as root it sends a message. What would be different if running as a cron. And how would I log it to see errors? Thanks Joe

 

4 Replies

  • Josh, That would probably help right? I have been trying it every way I can think of. Each time I change it I run /etc/init.d/crond restart Not sure if I have to but it can't hurt right.

     cron tab for root
    1-59/10 * * * * /usr/bin/diskmonitor
    0 */4 * * * /usr/bin/diskwearoutstat
    50 20 * * * /usr/bin/updatecheck -a
    50 20 21 * * /usr/bin/phonehome_activate
    */5 * * * * /home/Joe/Temperature.sh
     block 395320 
    
    */1 * * * * /usr/sbin/lsusb -v -d 0451:3410 >/dev/null
     end 395320 
    MAILTO=""
    54 * * * * /usr/bin/copy_rrd save
    

    It is the /home/Joe/Temperature.sh have also tried running it like

    */5 * * * * /etc/cron.hourly/Temperature.sh
    

    As well as

    */5 * * * * root /etc/cron.hourly/Temperature.sh
    */5 * * * * /home/admin/Temperature.sh
    */5 * * * * root /home/admin/Temperature.sh
    

    The script has to write a file locally and it can't seem to write it in cron.hourly so I keep moving it around. So the script runs a grep and writes a file. When it is in my home directory or home/admin it does the grep and writes the file but doesn't email it. If I copy the command out of the script and run it it will email the file as me or as root? Probably something stupid but I am stumped... Thanks for your help. Joe

  • BB16's avatar
    BB16
    Icon for Nimbostratus rankNimbostratus

    Hey Joe, Hope you are doing well. Can you please help sharing your temperature script here. this would be really helpful for me & even other users. Thank you.