-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathatlassian_rotate_tomcat_logs
executable file
·63 lines (54 loc) · 1.36 KB
/
atlassian_rotate_tomcat_logs
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
#!/bin/bash
# JIRA/Confluence do not have built in functionality to expire Tomcat logs:
# access_log.DATE
# catalina.DATE.log
# host-manager.DATE.log
# localhost.DATE.log
# manager.DATE.log
# This script will handle the expiration of Tomcat's log files
# with the exception of catalina.out which is handled by logrotate
# in /etc/logrotate.d/atlassian
# Must be root to run this script
if [ "`/usr/bin/id -urn`" != "root" ] ; then
echo -e "\nYou must be root to execute this script \n"
exit 1
fi
USAGE() {
echo -e "\nUsage: `basename $0` [ -c | -j ] "
echo -e "-c --> Rotate Confluence Tomcat logs"
echo -e "-j --> Rotate JIRA Tomcat logs"
}
INSTALL_DIR="/usr/local/atlassian"
SAVETIME=180
APP="null"
while getopts ":cj" OPT ; do
case $OPT in
c)
APP="confluence"
TOMCAT_LOG_DIR="$INSTALL_DIR/confluence/logs"
;;
j)
APP="jira"
TOMCAT_LOG_DIR="$INSTALL_DIR/jira/logs"
;;
\?)
echo -e "\nInvalid option: -$OPTARG" >&2
USAGE
exit 1
;;
:)
echo -e "\nOption -$OPTARG requires an argument" >&2
USAGE
exit 1
;;
esac
done
if [ "$APP" == "null" ] ; then
USAGE
exit 1
fi
if [ ! -r $TOMCAT_LOG_DIR ] ; then
echo -e "\nTomcat log directory $TOMCAT_LOG_DIR could not be accessed.\n"
exit 1
fi
find $TOMCAT_LOG_DIR -type f -name "*.????-??-??*" -mtime +$SAVETIME | xargs rm -vf