LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-27-2008, 06:30 PM   #1
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Rep: Reputation: 86
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...

Last edited by OlRoy; 02-27-2008 at 06:42 PM.
 
Old 02-27-2008, 06:47 PM   #2
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

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

ps aux | grep ntp

Last edited by billymayday; 02-27-2008 at 06:49 PM.
 
Old 02-27-2008, 07:11 PM   #3
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Original Poster
Rep: Reputation: 86
Yeah only ntpd is running. Is that what's causing this?
 
Old 02-27-2008, 07:49 PM   #4
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,018

Rep: Reputation: Disabled
Quote:
Originally Posted by OlRoy View Post
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.
 
Old 02-28-2008, 06:06 AM   #5
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Original Poster
Rep: Reputation: 86
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.
 
Old 02-28-2008, 06:42 AM   #6
scowles
Member
 
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620

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

0 * * * * root ntpdate us.pool.ntp.org
 
Old 02-28-2008, 07:05 AM   #7
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,018

Rep: Reputation: Disabled
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.
 
Old 02-28-2008, 07:17 AM   #8
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by scowles View Post
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...
 
Old 02-28-2008, 07:20 AM   #9
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Original Poster
Rep: Reputation: 86
Quote:
Originally Posted by Emerson View Post
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.
 
Old 02-28-2008, 07:33 AM   #10
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,773

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Use the full path to ntpdate command and the "-s" option:
Code:
0 * * * * /usr/sbin/ntpdate -s us.pool.ntp.org
 
Old 02-28-2008, 07:47 AM   #11
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Original Poster
Rep: Reputation: 86
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.
 
Old 02-28-2008, 07:51 AM   #12
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,018

Rep: Reputation: Disabled
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.
 
Old 02-28-2008, 07:57 AM   #13
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Original Poster
Rep: Reputation: 86
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.
 
Old 02-28-2008, 08:20 AM   #14
OlRoy
Member
 
Registered: Dec 2002
Posts: 304

Original Poster
Rep: Reputation: 86
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.
 
Old 02-28-2008, 08:24 AM   #15
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,018

Rep: Reputation: Disabled
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Job only runs when it is manually started sinister1 Linux - General 4 02-25-2008 08:35 AM
cron job runs but will not write to logfile c_curtis Linux - General 10 06-30-2006 09:25 AM
cron job only runs halfway aunquarra Linux - General 15 01-31-2005 04:53 PM
Why Does One Cron Job Runs Twice? cpope67 Programming 4 11-16-2004 06:09 AM
cron job to send file via ftp every 1 hour mcalizo Linux - Newbie 1 07-14-2004 03:50 AM


All times are GMT -5. The time now is 01:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration