"Fossies" - the Fresh Open Source Software Archive

Member "chrony-3.5/contrib/bryan_christianson_1/chronylogrotate.sh" (10 May 2019, 1512 Bytes) of package /linux/misc/chrony-3.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 #  chronyd/chronyc - Programs for keeping computer clocks accurate.
    4 #
    5 #  **********************************************************************
    6 #  * Copyright (C) Bryan Christianson  2015
    7 #  *
    8 #  * This program is free software; you can redistribute it and/or modify
    9 #  * it under the terms of version 2 of the GNU General Public License as
   10 #  * published by the Free Software Foundation.
   11 #  *
   12 #  * This program is distributed in the hope that it will be useful, but
   13 #  * WITHOUT ANY WARRANTY; without even the implied warranty of
   14 #  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15 #  * General Public License for more details.
   16 #  *
   17 #  * You should have received a copy of the GNU General Public License along
   18 #  * with this program; if not, write to the Free Software Foundation, Inc.,
   19 #  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   20 #  *
   21 #  **********************************************************************
   22 
   23 LOGDIR=/var/log/chrony
   24 
   25 rotate () {
   26   prefix=$1
   27 
   28   rm -f $prefix.log.10
   29 
   30   for (( count=9; count>= 0; count-- ))
   31   do
   32     next=$(( $count+1 ))
   33     if [ -f $prefix.log.$count ]; then
   34       mv $prefix.log.$count $prefix.log.$next
   35     fi
   36   done
   37 
   38   if [ -f $prefix.log ]; then
   39     mv $prefix.log $prefix.log.0
   40   fi
   41 }
   42 
   43 if [ ! -e "$LOGDIR" ]; then
   44   logger -s "missing directory: $LOGDIR"
   45   exit 1
   46 fi
   47 
   48 cd $LOGDIR
   49 
   50 rotate measurements
   51 rotate statistics
   52 rotate tracking
   53 
   54 #
   55 # signal chronyd via chronyc
   56 /usr/local/bin/chronyc cyclelogs > /dev/null
   57 
   58 exit $?