Lines Matching +full:current +full:- +full:rotate
4 # newlog - rotate log files
11 # The "logs" are kept compressed except for the current and
16 # -C "compress"
20 # -E "ext"
24 # -G "gens"
28 # -N Don't actually do anything, just show us.
30 # -R Rotate rather than save logs by default.
33 # -S Save rather than rotate logs by default.
37 # -f "fmt"
39 # uniquely name it when using the '-S' option.
41 # an extra suffix of our process-id.
43 # -d The "log" to be rotated/saved is a directory.
46 # -e Normally logs are only cycled if non-empty, this
49 # -g "group"
52 # -m "mode"
55 # -M "mode"
58 # -n "num"
61 # -o "owner"
64 # Regardless of whether '-R' or '-S' is provided, we attempt to
67 # we rotate.
81 # SPDX-License-Identifier: BSD-2-Clause
83 # @(#) Copyright (c) 1993-2016 Simon J. Gerraty
92 # Please send copies of changes and bug-fixes to:
109 -*) t=$1; shift;;
110 *) t=-x;;
115 for d in `IFS=:; echo ${2:-$PATH}`
123 # shell's typically have test(1) as built-in
128 _t=${3:-/}
130 case `test -$_o $_t 2>&1` in
132 *) eval test_$_o=-$_o;;
145 *) sm=-;;
150 gm=`echo $gm | sed 's,s,x,;s,S,-,'`
152 *) sm=${sm}-;;
159 *) sm=${sm}-;;
162 sed 's,rwx,7,g;s,rw-,6,g;s,r-x,5,g;s,r--,4,g;s,-wx,3,g;s,-w-,2,g;s,--x,1,g;s,---,0,g;s, ,,g'
168 $STAT -f %Op $1 | sed 's,.*\(....\),\1,'
173 fmode `find $1 -ls -prune | awk '{ print $3 }'`
179 $STAT -t "${2:-$opt_f}" -f %Sm $1
184 date "+${2:-$opt_f}"
201 test $# -gt 0 || exit 0 # nothing to do.
203 OS=${OS:-`uname`}
204 STAT=${STAT:-`Which stat`}
207 case "${opt_d:-0}" in
208 0) rm_f=-f
209 opt_d=-f
213 test -x $opt_C && break
215 empty() { test ! -s $1; }
217 *) rm_f=-rf
218 opt_d=-d
222 if [ -d $1 ]; then
223 n=`'ls' -a1 $1/. | wc -l`
224 [ $n -gt 2 ] && return 1
230 case "${opt_N:-0}" in
234 case "${opt_e:-0}" in
238 case "${opt_R:-0}" in
242 case "${opt_S:-0}" in
247 # see whether test handles -h or -L
248 test_opt L -h
251 -h,) test_L= ;; # we don't support either!
256 logs=`'ls' -ld $* | awk '{ print $NF }'`
265 "") 'ls' -ld $1 | awk '{ print $NF }'; return;;
268 'ls' -ld $1 | sed 's,.*> ,,'
284 -d) $ECHO mkdir -p $log;;
295 n=${2:-$opt_n}
298 $ECHO rm $rm_f `echo $log.$n | sed 's/\([0-9]\)$/[\1-9]*/'`
300 mode=${opt_m:-`get_mode $log`}
301 while test $n -gt 0
303 p=`expr $n - 1`
304 if test -s $log.$p; then
323 # unlike rotate_log we do not rotate files,
330 n=${2:-$opt_n}
336 test -s $last && $ECHO mv $last $log.$$;;
343 $ECHO rm -f $log.0
344 # remove excess logs - we rely on mtime!
345 $ECHO rm $rm_f `'ls' -1td $log.* 2> /dev/null | sed "1,${n}d"`
347 mode=${opt_m:-`get_mode $log`}
349 opt_S=${opt_S:-`get_mtime_suffix $log $fmt`}
355 # find a unique name to save current log as
367 $ECHO ln -s `basename $nlog` $log.0
376 *:[1-9]*)
377 set -- `IFS=:; echo $f`; f=$1; n=$2;;
390 -?)
403 n=`echo ,$opt_G, | sed -e "s,.*${f}:\([0-9][0-9]*\).*,\1,"`