Follow the below steps to configure tomcat (or any other process) to startup automatically at server reboot. This holds good for Linux 7 and above:
1. Navigate to /usr/lib/systemd/system/
2. Create a file called tomcat.service (Filename can be anything with .service extension)
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/libexec/tomcat/server start
User=root
[Install]
WantedBy=multi-user.target
3. Enable the service using below command:
systemctl enable tomcat
Note that above command will create a service named “tomcat”
4. Validate the service creation using below command
systemctl status tomcat
5. Now, reboot the server, and check the process status once it comes up
We can see that the process is started and systemctl status also shows the correct status.