File: adjtimex_parameters.sh

package info (click to toggle)
htpdate 2.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 236 kB
  • sloc: ansic: 763; sh: 126; makefile: 49
file content (35 lines) | stat: -rwxr-xr-x 781 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/sh
#
# In daemon mode htpdate writes the systematic drift of the clock to syslog.
# With this script you can convert the PPM drift values into adjtimex
# parameters. Only use this script when you know what you are doing.
#
# Consult adjtimex man page for more information.

if [ ! $1 ]; then
    echo "Usage: $0 <PPM> [current TICK] [current FREQ]"
    echo "By default TICK=10000 and FREQ=0"
    echo
    exit 1
fi

PPM=$1
TICK=10000
FREQ=0

if [ $2 ]; then
    TICK=$2
fi
    
if [ $3 ]; then
    FREQ=$3
fi

FREQTOT=`echo "$PPM * 65536 + $TICK * 6553600 + $FREQ" | bc`

TICK=`echo "$FREQTOT / 6553600" | bc`
FREQ=`echo "$FREQTOT % 6553600" | bc | awk -F. '{print $1}'`

echo "TICK=$TICK"
echo "FREQ=$FREQ"
echo "Suggested command: adjtimex -tick $TICK -frequency $FREQ"