I'm running centos 5.1 My problem is that ntpd does not sync time. After I leave server running for a few days it starts to fall behind. IF I leave it for a week it a few days behind. I fix it now by running /etc/init.d/ntpd stop ntpdate pool.ntp.org /etc/init.d/ntpd start I'm running this on vmware virtual system How do I fix this?
Falko, Why should you install the vmware tools for this problem?! Aren't the vmware tools just enhancements for the GUI? I've got the exact same problem and i've resolved it (temporarily) with a script that runs: ntpdate ntp.xs4all.nl every half hour. Not the best solution but it works for now.
I've just created the script below to do this: Code: #!/bin/bash var0=0 LIMIT=100000000000 while [ "$var0" -lt "$LIMIT" ] do ntpdate ntp.xs4all.nl sleep 108000 done echo exit 0
sorry if it sounds stupid but unless you can tell me where I need to put this file and how to make it run on schedule it makes no sense to me as I'm new to linux systems.
Using google I found that I need to save the script as text file and remove file extension. Then I need to put it in my server (I use WinSCP for that) /etc/cron.hourly Then I need to set permissions to 0755 And that the script will run next time cron executes? Is this right. Any help here would be great.
OK, here is a small guide how to use the script. But if you are using Vmware, you should install the vmware tools. 1. Create and edit a file called ntpsync.sh Code: cd /usr/bin touch ntpsync.sh joe ntpsync.sh (use your favorite editor) 2. Paste the following code in the file Code: #!/bin/bash var0=0 LIMIT=100000000000 while [ "$var0" -lt "$LIMIT" ] do ntpdate ntp.xs4all.nl sleep 108000 done echo exit 0 3. Give the file executable flags Code: chmod +x ntpsync.sh 4. Run the file Code: ./ntpsync.sh & You don't have to put this file in crontab. There is a counter in the file that goed one up every time it runs, but the limit is so high that it won't ever stop. You can remove this counter, but i was too lazy
Is there a reason to run it every 30mins? If I put it in /etc/cron.hourly and remove the counter it will run every hour right?
I created the script called ntpfix.sh with code: #!/bin/bash ntpdate ntp.xs4all.nl placed it in my /etc/cron.hourly Then restearted the server and turned off ntpd with /etc/init.d/ntpd stop To allow the script to run and when I after 6 hours or more do a manual command ntpdate pool.ntp.org I get 10000 or 15000 sec that is not normal if the command is execuded automatically every hour like it shoud have.
In what timezone are you living? I'm using ntp.xs4all.nl because i live in the Netherlands... You can replace ntp.xs4all.nl with pool.ntp.org
I changed my script to pool.ntp.org and now it is working fine. However how to I turn off autostart of ntpd so the script can run? Now I have to stop it manually.