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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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?
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.