Running ntpdate in ppp/ip-up.d

Hi, I am trying to get ntpdate to run when my dialup link comes up. This box is running Debian/stable. I have put a simple script in /etc/ppp/ip-up.d/ntpdate : #!/bin/sh /etc/init.d/ntpdate start All this script does is to run /usr/sbin/ntpdate -u -b -s $NTPSERVERS However the script hangs and ps indicates that it is sleeping ( S< ). It works fine if I run it manually (as root). Anyone know why it hangs? How do I make it work? Glenn -- Glenn Ramsey <glenn(a)componic.co.nz> 07 8627077 http://www.componic.co.nz

On 6/29/06, Glenn Ramsey <glenn(a)componic.co.nz> wrote:
Hi,
I am trying to get ntpdate to run when my dialup link comes up.
This box is running Debian/stable.
I have put a simple script in /etc/ppp/ip-up.d/ntpdate :
#!/bin/sh /etc/init.d/ntpdate start
All this script does is to run /usr/sbin/ntpdate -u -b -s $NTPSERVERS
However the script hangs and ps indicates that it is sleeping ( S< ). It works fine if I run it manually (as root).
Anyone know why it hangs? How do I make it work?
Glenn
On my debian/unstable to dial up requires it's own group which is not root. Therefore I suspect it needs those root permissions and not getting it. You can also run commands with strace in front of it and it will show you what system calls are going on. The last one shown should be the one sleeping... Ian -- Ian McDonald Web: http://wand.net.nz/~iam4 Blog: http://imcdnzl.blogspot.com WAND Network Research Group Department of Computer Science University of Waikato New Zealand

Ian McDonald wrote:
On 6/29/06, Glenn Ramsey <glenn(a)componic.co.nz> wrote:
Hi,
I am trying to get ntpdate to run when my dialup link comes up.
This box is running Debian/stable.
I have put a simple script in /etc/ppp/ip-up.d/ntpdate :
#!/bin/sh /etc/init.d/ntpdate start
All this script does is to run /usr/sbin/ntpdate -u -b -s $NTPSERVERS
However the script hangs and ps indicates that it is sleeping ( S< ). It works fine if I run it manually (as root).
Anyone know why it hangs? How do I make it work?
Glenn
On my debian/unstable to dial up requires it's own group which is not root. Therefore I suspect it needs those root permissions and not getting it.
You can also run commands with strace in front of it and it will show you what system calls are going on. The last one shown should be the one sleeping...
Ian
Thanks Ian, Some further info: it works if I use pon to bring the link up. But I am running linesrv and it is when linesrv brings the link up that ntpdate hangs. According to my linesrv.conf it uses /usr/bin/pon to bring the link up. linesrv is running as root. How would I use strace to diagnose that? Glenn -- Glenn Ramsey <glenn(a)componic.co.nz> 07 8627077 http://www.componic.co.nz

How would I use strace to diagnose that?
In one of your config files stick strace in front of it and redirect the output. e.g. if the command is blah put a line in something like: strace blah > /tmp/blah.txt You may need to install strace as a package if it is not installed already. The package is called strace. Ian -- Ian McDonald Web: http://wand.net.nz/~iam4 Blog: http://imcdnzl.blogspot.com WAND Network Research Group Department of Computer Science University of Waikato New Zealand

e.g. if the command is blah put a line in something like: strace blah > /tmp/blah.txt
strace outputs via stderr, so you'll need to do strace blah 2> /tmp/blah.txt I think this is probably overkill, as linesrv is running as root and it uses the same command to bring the ppp interface as Glenn would himself. Glenn: ntpdate will be hanging because it is unable to connect to the server it is trying to. It has a 60 second timeout or something, so after 60 seconds everything should come right. This obviously isn't ideal. It's possible the server you are trying to connect to is part of a round-robin pool, and it's getting a dead server occasionally. If you tell ntp to try several servers at once you should (I think!) improve the odds. Alternatively, you could try a short sleep before running ntpdate, although that might just increase the delay between things working. Finally, you could always background the ntpdate process and carry on. In your ip-up script, put a & after the line that calls ntpdate, etc: /etc/init.d/ntpdate start & This will background the command and let it complete in its own time, and the rest of the process will carry on as normal.
participants (3)
-
Daniel Lawson
-
Glenn Ramsey
-
Ian McDonald