BigAdmin System Administration Portal
Community-Submitted Tech Tip
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

Rotation of Access and Error Logs for Sun Java System Web Server 6

Andre Cervera, November 2007

There are a bunch of ways to rotate the access and error logs for the Sun Java System Web Server. I'll discuss some of them and then show the way I think is best.

Note: The procedure here was tested on Sun Java System Web Server 6.0 and 6.1 on the Solaris Operating System, releases 10, 9, and 8. A different procedure is needed for Sun Java System Web Server 7.0.

The simplest way is to use crontab to execute /opt/iplanet/servers/iplanet instance #n/rotate. Here is a sample configuration:

bash-3.00# crontab -l | grep rotate
### rotate iplanet access & errors log
0 0 * * * /opt/iplanet/servers/iplanet instance #1/rotate
0 0 * * * /opt/iplanet/servers/iplanet instance #2/rotate

Another way is to use the Solaris logadm utility. Here is a sample configuration:

bash-3.00# grep iplanet /etc/logadm.conf
# rotate iplanet access & errors log
iPlanet1 -a 'kill -HUP\
`cat /opt/iplanet/servers/iplanet instance #1/logs/pid`'\
-t '/opt/iplanet/servers/iplanet instance #1/logs/$basename.%d'\
-z 0\
'/opt/iplanet/servers/iplanet instance #1/logs/*{access,errors}'
iPlanet2 -a 'kill -HUP\
`cat /opt/iplanet/servers/iplanet instance #2/logs/pid`'\
-t '/opt/iplanet/servers/iplanet instance #2/logs/$basename.%d'\
-z 0\
'/opt/iplanet/servers/iplanet instance #2/*{access,errors}'
bash-3.00# crontab -l | grep -i iplanet
### rotate iplanet access & errors log
0 0 * * * /usr/sbin/logadm -p now iPlanet1 iPlanet2

In the first example above, you need to set your editor, crontab -e, and hash the rotate entries to disable rotation and un-hash the rotate entries to enable log rotation.

In the second example above, doing a kill -HUP iplanet PID releases the process that writes the access and error file in memory, which is not recommended in a 24/7/365 web environment.

Below is what I think is the best way to rotate the log files.

1. Create the following files:

bash-3.00# vi \
/opt/iplanet/servers/https-admserv/config/scheduler.conf
<Object name=iplanet instance #1/_rotatelg0>
    Command "/opt/iplanet/servers/iplanet instance #1/rotate"
    User root
    Time 0:00
    Days Sun Mon Tue Wed Thu Fri Sat
</Object>
<Object name=iplanet instance #2/_rotatelg0>
    Command "/opt/iplanet/servers/iplanet instance #2/rotate"
    User root
    Time 0:00
    Days Sun Mon Tue Wed Thu Fri Sat
</Object>
bash-3.00# vi /opt/iplanet/servers/https-admserv/config/
  schedulerd.conf
ConfFile /opt/iplanet/servers/https-admserv/config/scheduler.conf
Dir /tmp
Status on

2. Create a startup/shutdown script:

bash-3.00$ vi /etc/init.d/schedulerd
#!/sbin/sh
#
#
# To restart, start, or stop the iPlanet schedulerd
# control daemon from command line
#
# Work Around for Bug ID: 6528670
# Initially scripted by acervera
# Date: 09/26/2007

SERVER_ROOT=/opt/iplanet/servers
ADMSERV_ROOT=$SERVER_ROOT/https-admserv/config
PID_FILE=$SERVER_ROOT/https-admserv/logs/scheduler.pid
export SERVER_ROOT ADMSERV_ROOT PID_FILE

case "$1" in
'start')
	cd $SERVER_ROOT/bin/https/bin
	./schedulerd -d $SERVER_ROOT
	;;

'stop')
	kill -9 -`cat $PID_FILE`
	rm $PID_FILE
	;;

*)
	echo "Usage: $0 { start | stop }"
	exit 1
	;;
esac
exit 0

3. For the Solaris 10 OS, complete the following substeps. For the Solaris 9 or 8 OS, use step 4 instead.

a. Create a schedulerd.xml file:

bash-3.00$ mkdir -p /var/svc/manifest/application/iplanet
bash-3.00$ vi /var/svc/manifest/application/iplanet/schedulerd.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM
"/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
	Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
	Use is subject to license terms.
	ident	"@(#)webmin.xml	1.1	04/11/11 SMI"

	Service manifest for iPlanet schedulerd service.
-->

<service_bundle type='manifest' name='schedulerd'>

<service
	name='application/iplanet/schedulerd'
	type='service'
	version='1'>

	<create_default_instance enabled='false' />

	<single_instance/>

	<dependency
		name='filesystem'
		grouping='require_all'
		restart_on='none'
		type='service'>
		<service_fmri value='svc:/system/filesystem/local' />
	</dependency>

	<dependency
		name='network'
		grouping='require_all'
		restart_on='none'
		type='service'>
		<service_fmri value='svc:/network/initial' />
	</dependency>

	<exec_method
		type='method'
		name='start'
		exec='/etc/init.d/schedulerd start'
		timeout_seconds='30' >
	</exec_method>

	<exec_method
		type='method'
		name='stop'
		exec='/etc/init.d/schedulerd stop'
		timeout_seconds='60' />

	<stability value='Unstable' />

	<template>
		<common_name>
			<loctext xml:lang='C'>
iPlanet schedulerd
			</loctext>
		</common_name>
	</template>
</service>

</service_bundle>

b. Import the schedulerd.xml data into the repository:

bash-3.00# svccfg -v import \
/var/svc/manifest/application/iplanet/schedulerd.xml
svccfg: Taking "initial" snapshot for
svc:/application/iplanet/schedulerd:default.
svccfg: Taking "last-import" snapshot
for svc:/application/iplanet/schedulerd:default.
svccfg: Refreshed svc:/application/iplanet/schedulerd:default.
svccfg: Successful import.

c. Enable the Sun Java System Web Server schedulerd control daemon so that it always runs at boot time:

bash-3.00# svcadm enable \
svc:/application/iplanet/schedulerd:default

4. On the Solaris 9 or 8 OS, complete the following substeps:

a. Create soft links for /etc/init.d/schedulerd to stop the scheduler at shutdown and start it at boot time.

bash-3.00# ln -s /etc/init.d/schedulerd /etc/rc3.d/S80schedulerd
bash-3.00# ln -s /etc/init.d/schedulerd /etc/rcS.d/K05schedulerd
bash-3.00# ln -s /etc/init.d/schedulerd /etc/rc2.d/K05schedulerd
bash-3.00# ln -s /etc/init.d/schedulerd /etc/rc1.d/K05schedulerd
bash-3.00# ln -s /etc/init.d/schedulerd /etc/rc0.d/S05schedulerd

b. Start the Sun Java System Web Server schedulerd control daemon:

bash-3.00# /etc/init.d/schedulerd start

Editor's Note: "iplanet" in the code above refers to the previous name of the Web Server, formerly known as Sun ONE or iPlanet Web Server.

About the Author

Andre Cervera is an SCSECA, SCNA, SCSA, HP-UX ITCP, and UNIX systems architect/engineer for the City of New York Department of Information Technology and Telecommunications. He has been working as a UNIX enterprise systems engineer for over eight years in the industry. He may be reached at acervera [at] doitt.nyc.gov.

The information and links on this page have been provided by a BigAdmin user. The submitter is solely responsible for such information and links. Sun is not responsible for the availability of external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable, directly or indirectly, for any actual or alleged damage or loss caused by or in connection with use of or reliance on the information posted here, or goods or services available on or through any external site or resource.
 
 

Comments (latest comments first)

Discuss and comment on this resource in the BigAdmin Wiki

Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin