You are not logged in.
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
Offline
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
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
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
thanks for help! take the 1st option! but other ones also nice. works great.
sorry for my bad english
Offline