Forum Discussion
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
Can you paste a copy of your cron configuration?
- sundogbrewAltocumulus
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
Sounds like a crontab PATH environment problem. In this post you'll find some tips on how to verify that this is indeed the cause of your problems and how to fix it.
https://stackoverflow.com/questions/2388087/how-to-get-cron-to-call-in-the-correct-paths
Restarting the crond shouldn't be necessary. Just make sure you use the
command to edit the crontab and verify your changes withcrontab -e
.crontab -l
- BB16Nimbostratus
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.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com