File: rotate-logs.sh.in

package info (click to toggle)
zmailer 2.99.51.52pre3-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 16,596 kB
  • ctags: 7,422
  • sloc: ansic: 90,470; sh: 3,608; makefile: 2,784; perl: 1,585; python: 115; awk: 22
file content (41 lines) | stat: -rw-r--r-- 669 bytes parent folder | download
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
36
37
38
39
40
41
#!/bin/sh
#
#  Log-rotation utility for ZMailer
#
#  Your mileage may vary as you tune your loggings
#  At nic.funet.fi we use this DAILY, elsewere it
#  can be used weekly to monthly...
#

ZCONFIG=@ZMAILERCFGFILE@
. $ZCONFIG

cd $LOGDIR

FILES="router scheduler smtpserver smtp"

for x in $FILES
do
	# cut, and compress
	for y in 8 7 6 5 4 3 2 1 0
	do
		z=`expr $y + 1`
		if [ -f $x.$y.gz ]; then
		    /bin/mv $x.$y.gz $x.$z.gz
		fi
	done
	if [ -f $x ]; then
		/bin/mv	$x $x.0
		/bin/touch $x
	fi
done

$MAILBIN/zmailer logsync

# Sleep here to let the logsync to take effect
#  -- what ? half an hour ?
sleep 1800

# Compress the newly separated log files
gzip *.0