#!/bin/bash # # script to check whether the time of the computer is off # offset is inserted into the database # offset=`/usr/sbin/ntpdate -d ptbtime1.ptb.de 2>/dev/null | grep '^offset*' | cut -d' ' -f2` query="INSERT NTPDate SET fOffset="$offset", fMachineKEY=(SELECT fMachineKEY FROM Machine WHERE fMachineName='"$HOSTNAME"'), fTime=Now()" # host needs full address to work also on fact01 /usr/bin/mysql -u systemstatus --host=fact01 systemstatus -e "$query" if [ $(echo " $offset > 1 || $offset < -1 " | bc) -eq 1 ] then echo `date`": time difference of "$offset" sec on "$HOSTNAME fi