On Jan 11, 6:52 pm, Unruh <[email protected]> wrote: > And alter your script so that it does not try to write any file on today or > earlier. Or test to see if peerstats and peerstats.20090201 are the same > file (same inode with ls -li) >
This is a good idea. I have changed my script and it seems to work now: #!/bin/sh # this script syncs ntp stats to a nfs directory # Author: Thorsten Muehlfelder <[email protected]> # Version: 0.12 # ################################################################################ # where are the ntpd stats? STATS_DIR="/mnt/stats" # which ntpd stats should be copied? STATS="cryptostats loopstats peerstats rawstats sysstats" # where is my config file? CONFIG="/etc/nfs-sync.conf" ################################################################################ # If possible, log events in /var/log/messages: if [ -f /var/run/syslogd.pid -a -x /usr/bin/logger ]; then LOGGER=/usr/bin/logger else # output to stdout/stderr: LOGGER=/bin/cat fi # get the configuration information from /etc/nfs-sync.conf if [ -r $CONFIG ]; then . $CONFIG else echo "nfs-sync.sh: config file does not exist or is not readable" | $LOGGER exit 1 fi # cd into ntpd stats dir if [ -d $STATS_DIR ]; then cd $STATS_DIR else echo "nfs-sync.sh: stats dir does not exist" | $LOGGER exit 1 fi # mount the nfs directory and check the exit status mount -t nfs ${NFSSERVER}:${EXPORT} $IMPORT > /dev/null 2>&1 if [ $? = 0 ]; then for FILENAME1 in ${STATS}; do # get the inode INODE1=`ls -li $FILENAME1 | gawk '{print $1}'` for FILENAME2 in ${FILENAME1}.????????; do # get the inode INODE2=`ls -li $FILENAME2 | gawk '{print $1}'` # skip the statistic file, if inodes are the same if [ "$INODE1" = "$INODE2" ]; then continue fi # move statistic files to the nfs directory mv $FILENAME2 $IMPORT > /dev/null 2>&1 done # move gzipped statistic files to the nfs directory mv ${FILENAME1}.????????.gz $IMPORT > /dev/null 2>&1 # copy the actual day statistic files to the nfs directory cp -f $FILENAME1 $IMPORT > /dev/null 2>&1 done # make sure to write everything to disk sync # umount the nfs directory umount $IMPORT else echo "nfs-sync.sh: mount.nfs system call failed" | $LOGGER for FILENAME1 in ${STATS}; do # get the inode INODE1=`ls -li $FILENAME1 | gawk '{print $1}'` for FILENAME2 in ${FILENAME1}.????????; do # get the inode INODE2=`ls -li $FILENAME2 | gawk '{print $1}'` # skip the statistic file, if inodes are the same if [ "$INODE1" = "$INODE2" ]; then continue fi # gzip the statistic files gzip $FILENAME1 > /dev/null 2>&1 done done fi _______________________________________________ questions mailing list [email protected] https://lists.ntp.org/mailman/listinfo/questions
