-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathiwsLogScript.ksh
86 lines (63 loc) · 2.15 KB
/
iwsLogScript.ksh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/ksh
#
# IWS Log Script
# Dependancies: None
#
# This script copies the I-Planet Web Server log files to a log directory.
# It names the resulting log files with the host name and date.
#
# WARNING: THIS SCRIPT DELETES ANY FILES OLDER THAN 7 DAYS in the
# $LOGDIR directory!!!
#
## Submitter Email: [email protected]
#*****************************************************************
PATH=/usr/sbin:/usr/bin
# Where the log files will be written to
LOGDIR=/app/weblog
DATE=`date '+%m-%d-%y%n'`
if [ ! -d $LOGDIR ] ; then
mkdir -p $LOGDIR
fi
HOSTNAME=`uname -n`
WEBDIR=/app/netscape/suitespot/https-$HOSTNAME/logs
# IWS output file
FILE=$WEBDIR/access
# Resulting log file
LOGFILE=$LOGDIR/access.$HOSTNAME
# Log the output
cp $FILE $LOGFILE
# Over-write the IWS access log file while preserving the first line.
# The first line provides log formatting information. If it is deleted,
# the web server will not start and give a formatting error message.
head -1 $LOGFILE > $FILE
# Delete any log files older than 7 days
find $LOGDIR -mtime +7 -exec rm {} \;
# Ensure that the log files do not take up more than 50 MB
# The maximum size $OUTPUTDIR is allowed to reach before log files
# are deleted. (51200=50 MB)
MAXSIZ=51200
# The next variable can be set for multiple addresses
# (i.e. [email protected],[email protected])
MAILADD=status
LOGDU=`du -sk $LOGDIR | awk '{ print $1 }`
if [ "$LOGDU" -gt "$MAXSIZ" ]; then
mail $MAILADD <<EOF
From: $0
Subject: Web Log Size on $HOSTNAME
$LOGDIR is $LOGDU KB. $0 notifies of
more than 50 MB of log files in this directory.
Thank you.
EOF
fi
exit 0
##############################################################################
### This script is submitted to BigAdmin by a user of the BigAdmin community.
### Sun Microsystems, Inc. is not responsible for the
### contents or the code enclosed.
###
###
### Copyright 2005 Sun Microsystems, Inc. ALL RIGHTS RESERVED
### Use of this software is authorized pursuant to the
### terms of the license found at
### http://www.sun.com/bigadmin/common/berkeley_license.html
##############################################################################