Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
when i run the script as "sh /root/Scripts/NTP" then it runs perfectly
but in cron it some how doesn't work. "tailf /var/log/cron | grep NTP" shows cron job is been executed but in " /root/Scripts/ntp.log" i don't see the logs but when i run the script separately i get logs in "/root/Scripts/ntp.log"
Script is perfect & other cron jobs are working fine.
Only this particular script is giving problem.
The only thing that comes to mind is permissions. cron is a bit fussy about what the exact permissions are. I've been bitten by this problem where something will run manually as a script but won't run in a cron context. Have you checked to make sure that NTP has the same permissions as the other scripts that do run successfully in cron have?
cheers,
jdk
Hi Maxy,
Hmmmmm. I just solved a problem with a script that I put in /etc/cron.hour. Since my isp changes the ip of the router regularly and I hate laptops I need to use ssh to access my system whenever I travel. So I needed a way of checking regularly to see if my routers ip had changed recently and if so then run a ddclient script to update my dynamic dns site. Just like your case, it didn't work from cron but if I ran the script manually it would work. Then I RTFM-ed the cron man page and found my script, called whatismyip.sh contained a full-stop (".") in the file name which is not allowed by cron. I removed the full-stop and now the script runs perfectly every hour and only runs the ddclient script when my router's ip has actually changed.
All this to say, your log file has a full-stop in the filename. It seems that should be ok but what if you changed the file name to ntp_log just to make sure that is not the problem.
cheers,
jdk
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.