sixtydoses. where od is harmless.

January 22, 2010

Autostart tomcat upon reboot.

Filed under: Tech — Tags: , , , , — od @ 1:04 pm

So this morning they shutdown the server and called me up complaining that the website is down.

No, I didn’t ask how many times have they rebooted. Lol.

Anyway the website is down because I didn’t configure both apache and tomcat to run automatically upon reboot. Am so lazy today because it’s Friday, basically it’s a yippee day,  a day that is legal for you to come to work late, and go back early.

Googled for the auto script, but none satisfied my needs, so, here’s mine (adapted from a couple of scripts), because sharing is caring.

This script will always run tomcat as user ‘admin’ (EUID 500). If you run the script as a different user, it’ll prompt for admin’s password. Dump the script in /etc/init.d/ and run chkconfig to configure runlevel startup.

# tomcat     This is the init.d script used to start tomcat.
#                It calls $CATALINA_HOME/bin/ or
# chkconfig: – 91 15
# description: Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies.
# processname: tomcat

export JAVA_HOME=/usr/java/jdk1.6.0_16
export CATALINA_HOME=/usr/local/apache-tomcat-5.5.28

tomcat_stop() {
if [[ $EUID -ne 500 ]]; then
su -c ‘$CATALINA_HOME/bin/’ admin
exit 1

tomcat_start() {
if [[ $EUID -ne 500 ]]; then
su -c ‘$CATALINA_HOME/bin/’ admin
exit 1

case $1 in
echo -n “Starting Tomcat server:”
echo “.”
echo -n “Stopping Tomcat server:”
echo “.”
echo “Usage: /etc/init.d/tomcat start|stop”



  1. Once again, my darling baby proves that she is an expert programmer and script writer! So proud of you honey!!!

    Comment by devin — January 22, 2010 @ 10:55 pm

  2. Oh my I bet you’d be ecstatic if I start writing kernel code <_<


    Comment by od — January 23, 2010 @ 8:18 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: