Step 1) Login as root and create tomcat.service file
[root@tomcathost ~]# cd /etc/systemd/system/
[root@tomcathost system]# cat>tomcat.service
[Unit]
Description=tomcat service
After=network.target
[Service]
User=osboxes
Group=osboxes
Type=oneshot
ExecStart=/home/osboxes/instances/poc-tomcat-instance/bin/startup.sh
ExecStop=/home/osboxes/instances/poc-tomcat-instance/bin/shutdown.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Step 2) Reload systemctl daemon
[root@tomcathost system]# systemctl daemon-reload
Step 3) Enable tomcat service
[root@tomcathost system]# systemctl enable tomcat.service
Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.
Step 4) Start tomcat service
[root@tomcathost ~]# systemctl start tomcat
Step 5) reboot the machine
[root@tomcathost system]# init 6
Step 6) Check the tomcat jvm process status after machine reboot
[osboxes@tomcathost ~]$ ps -ef | grep java
osboxes 817 1 10 02:47 ? 00:00:07 /home/osboxes/products/jdk/jdk_latest/jre/bin/java -Djava.util.logging.config.file=/home/osboxes/instances/poc-tomcat-instance/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -Xloggc:/home/osboxes/logs/poc-tomcat-instance/GC.log -server -d64 -Xms1024m -Xmx1024m -Djava.library.path=/home/osboxes/products/tomcat/tomcat90/lib -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /home/osboxes/products/tomcat/tomcat90/bin/bootstrap.jar:/home/osboxes/instances/poc-tomcat-instance/bin/tomcat-juli.jar -Dcatalina.base=/home/osboxes/instances/poc-tomcat-instance -Dcatalina.home=/home/osboxes/products/tomcat/tomcat90 -Djava.io.tmpdir=/home/osboxes/instances/poc-tomcat-instance/temp org.apache.catalina.startup.Bootstrap start
You can also verify the boot.log
[root@tomcathost ~]# grep tomcat /var/log/boot.log
Starting tomcat service...
[ OK ] Started tomcat service.
No comments:
Post a Comment