Automatically start Tomcat on instance startup/reboot in Amazon EC2-Instance

Shreyank Byadagi
1 min readMay 1, 2020

--

As we all know that Apache Tomcat is not configured with autostart by default in Ubuntu. So, custom init script is required to configure Tomcat for autostart on startup.

So follow these steps in order to start tomcat automatically on instance reboot:

  1. Once you login in to the AWS instance from terminal, switch to root user by executing following command.
sudo su -

2. Navigate to etc/init.d directory by executing following command.

cd /etc/init.d

3. Now create an init script with name tomcat9 (depends on your tomcat version, if your using tomcat 8 name the script as tomcat8) in etc/init.d directory.

Note: Do not append .sh to tomcat9 file

4. Now do a vi on tomcat9 file with the following command

vi tomcat9

5. Add the contents of the below mentioned code in tomcat9 script

Note: Ensure you have same tomcat installation folder path at line 15 and 19

6. Change the permissions tomcat9 file by executing following commands.

chmod 755 /etc/init.d/tomcat9update-rc.d tomcat9 defaults

With this tomcat will automatically start on instance bootup !!!

--

--

Shreyank Byadagi
0 Followers

Ex-Finflux | Tech Blogger | Full-Stack Developer