You are not logged in.

#1 2005-01-30 23:57:27

iggy
Member
From: Germany, L.E. - Leipzig
Registered: 2004-10-17
Posts: 367

execute ntpdate at system-startup, how to do?

hello!

i want to realize, that ntpdate syncs my clock at system-startup. i can create a script. but how to do that? plz help me.
these lines i want to execute

ntpdate ntps1-1.cs.tu-berlin.de
hwclock --systohc

thx for help


sorry for my bad english smile

Offline

#2 2005-01-31 00:52:30

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: execute ntpdate at system-startup, how to do?

add them to /etc/rc.local


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#3 2005-01-31 00:56:10

cs25x
Member
Registered: 2004-05-04
Posts: 150

Re: execute ntpdate at system-startup, how to do?

Before you do, check htpdate from freshmeat, it is very good, uses http calls to get the time. I run this in /etc/rc.local

Now how to make a script

#!/bin/sh

your code
more
your code

And that is it.

If you call one script from another and you want to pass values via the environment,  then

#!/bin/sh

. your code

is the thingto do, and not get caught with lost environments. The '.' runs your code using the current shell, otherwise it launches a new shell.

Keeping the same shell can be useful, e.g. I call a script I call connect at the beginning of all my web sucker scripts, this limits the speed for wget and rsynch to make it friendly for other users on the net. So, is have to set a variable and export it.
connect:

#!/bin/sh
export WGspeed=10k
export RSspeed=30

--(*(cs25x--));

Offline

#4 2005-01-31 01:31:45

alterkacker
Member
From: Peoples Republic of Boulder
Registered: 2005-01-08
Posts: 52

Re: execute ntpdate at system-startup, how to do?

I replaced the first part of /etc/rc.d/ntpd with the following:

PID=`pidof -o %PPID /usr/bin/ntpd`
ntpstep=/etc/ntp/step-tickers
case "$1" in
  start)
    stat_busy "Spawning time server setup"
    (
      tickers=''
      if [ -s "$ntpstep" ]; then
        tickers=`/bin/sed -e 's/#.*$//g' $ntpstep`
        /usr/bin/ntpdate -s -b -p 8 -u $tickers >/dev/null 2>&1
      fi
      if [ -z "$PID" ]; then 
         /usr/bin/ntpd &
      fi
      if [ ! -z "$PID" -o $? -gt 0 ]; then
        :
      else
        add_daemon ntpd
      fi
    ) &
    stat_done
    ;;
  stop)

where /etc/ntp/step-tickers lists the servers I want & looks like:

utcnist.colorado.edu
tick.usnogps.navy.mil

The 'ntpdate' step can take some time and this way the whole thing runs in the background.

Offline

#5 2005-01-31 16:58:40

iggy
Member
From: Germany, L.E. - Leipzig
Registered: 2004-10-17
Posts: 367

Re: execute ntpdate at system-startup, how to do?

thanks for help! take the 1st option! but other ones also nice. works great.


sorry for my bad english smile

Offline

Board footer

Powered by FluxBB