LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   NTP cron job runs every 5 min instead of hour (https://www.linuxquestions.org/questions/linux-networking-3/ntp-cron-job-runs-every-5-min-instead-of-hour-624326/)

OlRoy 02-27-2008 06:30 PM

NTP cron job runs every 5 min instead of hour
 
I can't figure this out. I have the following crontab entry

Code:

0 * * * * ntpdate us.pool.ntp.org
It should go once ever hour, but according to tcpdump I see the NTP traffic around once every 5 minutes.

Code:

19:11:33.389970 IP 192.168.1.107.123 > 63.240.161.99.123: NTPv4, Client, length 48
19:11:33.441194 IP 63.240.161.99.123 > 192.168.1.107.123: NTPv4, Server, length 48
19:16:57.349480 IP 192.168.1.107.123 > 63.240.161.99.123: NTPv4, Client, length 48
19:16:57.401427 IP 63.240.161.99.123 > 192.168.1.107.123: NTPv4, Server, length 48
19:21:18.346288 IP 192.168.1.107.123 > 63.240.161.99.123: NTPv4, Client, length 48
19:21:18.397088 IP 63.240.161.99.123 > 192.168.1.107.123: NTPv4, Server, length 48
19:26:41.349543 IP 192.168.1.107.123 > 63.240.161.99.123: NTPv4, Client, length 48
19:26:41.404663 IP 63.240.161.99.123 > 192.168.1.107.123: NTPv4, Server, length 48

I have no clue what's going on... does anyone know how to fix this?

Update: I just deleted the cronjob with crontab -r and it is still syncing every 5 minutes, and I still can't figure it out...

billymayday 02-27-2008 06:47 PM

See if there's a daemonised process or similar running (are you running ntpd?)

ps aux | grep ntp

OlRoy 02-27-2008 07:11 PM

Yeah only ntpd is running. Is that what's causing this?

Emerson 02-27-2008 07:49 PM

Quote:

Originally Posted by OlRoy (Post 3072043)
Yeah only ntpd is running. Is that what's causing this?

Yep, and this is something you want to keep running. Even computer security relies on correct time.

OlRoy 02-28-2008 06:06 AM

Well I tried disabling NTPD and only using a cron ntpdate job, but no NTP traffic was sent. Which is odd since I can use ntpdate manually and NTP traffic is sent so I don't know why cron isn't working.

scowles 02-28-2008 06:42 AM

Try adding a "user" to cron job entry. Example:

0 * * * * root ntpdate us.pool.ntp.org

Emerson 02-28-2008 07:05 AM

ntpd does more than you think, it keeps correct time even between syncing using drift file. I do not understand why someone would want to disable it.

OlRoy 02-28-2008 07:17 AM

Quote:

Originally Posted by scowles (Post 3072503)
Try adding a "user" to cron job entry. Example:

0 * * * * root ntpdate us.pool.ntp.org

I have the following crontab entry now and it still isn't working. :(

2 * * * * * root ntpdate us.pool.ntp.org
1 * * * * * root echo Testing

I checked and the crond is running as well. This is all on a Red Hat 9 box if it matters...

OlRoy 02-28-2008 07:20 AM

Quote:

Originally Posted by Emerson (Post 3072524)
ntpd does more than you think, it keeps correct time even between syncing using drift file. I do not understand why someone would want to disable it.

I'm just trying to get it working and disabled it for trouble shooting. How can I get ntpd to sync once every 30 or maybe 60 minutes instead of every 5 minutes? If I can't figure out why cron isn't working I'll use ntpd, but I'd really like to get cron working just so I know what in the heck is going on.

bathory 02-28-2008 07:33 AM

Use the full path to ntpdate command and the "-s" option:
Code:

0 * * * * /usr/sbin/ntpdate -s us.pool.ntp.org

OlRoy 02-28-2008 07:47 AM

Man with your suggestion and what I just found on a website I thought I had it. The website said use */n * * * * command to run something every n minutes. My current crontab looks like this

Code:

1 * * * * /usr/sbin/ntpdate -s us.pool.ntp.org
*/2 * * * * /usr/sbin/ntpdate -s us.pool.ntp.org

After a few minutes of waiting I still don't see any NTP traffic.

Emerson 02-28-2008 07:51 AM

Yes, but if your computer clock is not accurate enough then running ntpdate will cause time jumps. Depending how big those jumps are you may get weird errors.

OlRoy 02-28-2008 07:57 AM

Emerson, then how can I tell ntpd how often I want it to sync to the NTP server? I haven't found anything in the /etc/ntp.conf or google on how to do that.

OlRoy 02-28-2008 08:20 AM

It works! I just checked my mail and cron was complaining that the root command wasn't found so I deleted root and cron finally works now. Thanks for everyones help!

Emerson I'm still interested in using ntpd if it's possible to change how often it syncs with the ntp server.

Emerson 02-28-2008 08:24 AM

Is it new install? Once ntpd gets "familiar" with your computer clock it should increase the sync interval to 1024 s, isn't this interval long enough?

OlRoy 02-28-2008 08:35 AM

Yeah it's a new install. I guess I never did give it a chance to get familiar with my system. I'll give it another try... Thanks for everyones help!

Emerson 02-28-2008 08:37 AM

If it's new install then there is absolutely NO EXCUSE to run RH-9. Please consider installing a modern Linux distro. Besides security risks you are missing out on tons of new features.

http://www.linuxquestions.org/questi...-linux-524947/

acid_kewpie 02-28-2008 10:51 AM

you don't tell ntpd how often to sync, it doesn't work like that, and it's kind of the case that you need to appreciate that it has reasons to do what it does.

ntpd will eventually slow down automatically to synchronize once every 1024 seconds, about 17 minutes. but if it is doing it more often than this then it has a good reason to. i found ntpd to be real black magic until i found the ntpq command. run "ntpq -pn" and you can see the current state of the ntp daemon. how often it's query the remote servers, which one's it's using etc... it's really an eye opener once you look at that.

that said i've had awful trouble getting a reliable time source under vmware and did have to use a cold hard ntpdate command to reign it in, but that's a very different story.

oh hey, there was a 2nd page!


All times are GMT -5. The time now is 09:22 PM.