Automatic Starting Tomcat on ubuntu

  1. Create a new file to write the code to run on computer start-up:
    Open a new file using the following command from terminal:
    sudo vi /etc/init.d/tomcat
    or
    sudo gedit /etc/init.d/tomcat
  2. Copy the below code in the new tomcat file opened:
    # Tomcat auto-start
    # description: Auto-starts tomcat
    # processname: tomcat
    # pidfile: /var/run/tomcat.pid
    export JAVA_HOME=/usr/lib/jvm/java-6-sun
    case $1 in
    start)
    sh /usr/local/tomcat/bin/startup.sh
    ;;
    stop)
    sh /usr/local/tomcat/bin/shutdown.sh
    ;;
    restart)
    sh /usr/local/tomcat/bin/shutdown.sh
    sh /usr/local/tomcat/bin/startup.sh
    ;;
    esac
    exit 0NOTE: change the path mentioned in above code, if the file path is different on your system.
  3. Make the script executable by running the chmod command:
    sudo chmod 755 /etc/init.d/tomcat
  4. Link this script to the startup folders with a symbolic link:
    sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
    sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
  5. Restart the system and tomcat start automatically:
    Open any browser and type localhost:8080/ to see the tomcat home page.

About the Author

Sandeep Agrawal
working @ Kalpavruksh Technologies as Software Engineer. I am a simple and straightforward person adaptable to any environment and work culture. Like to work in a creative and challenging environment using cutting edge technologies where I could constantly learn and successfully deliver solutions to problems.

Be the first to comment on "Automatic Starting Tomcat on ubuntu"

Leave a comment

Your email address will not be published.


*


0 Shares
Tweet
Pin
Share
Share
Share
%d bloggers like this: