{"id":362,"date":"2009-05-27T22:31:38","date_gmt":"2009-05-27T15:31:38","guid":{"rendered":"http:\/\/adityo.blog.binusian.org\/?p=362"},"modified":"2009-07-15T19:05:01","modified_gmt":"2009-07-15T12:05:01","slug":"redhat-run-level-and-how-to-make-tomcat-service-to-run-on-boot-time-in-centos","status":"publish","type":"post","link":"https:\/\/adityo.blog.binusian.org\/?p=362","title":{"rendered":"Redhat run level and how to make tomcat service to run on boot time in CentOS"},"content":{"rendered":"<p>Just today one of my friend are pm me and ask how to make his tomcat service at \/etc\/init.d\/tomcat to run when the server reboot. At the first time i just tell him to use chkconfig because the os that he use was CentOS<\/p>\n<p>What is chkconfig ?<\/p>\n<p>Chkconfig is a basic system utility. It updates and queries runlevelinformation for system services. Chkconfig manipulates the numerous symbolic links in \/etc\/rc*.d, to relieve system administrators of some of the drudgery of manually editing the symbolic links.<\/p>\n<p><strong>chkconfig<\/strong> <strong>&#8211;list<\/strong> [<em>name<\/em>]<br \/>\n<strong>chkconfig<\/strong> <strong>&#8211;add<\/strong> <em>name<\/em><br \/>\n<strong>chkconfig<\/strong> <strong>&#8211;del<\/strong> <em>name<\/em><br \/>\n<strong>chkconfig<\/strong> [<strong>&#8211;level<\/strong> <em>levels<\/em>] <em>name<\/em> &lt;<strong>on<\/strong>|<strong>off<\/strong>|<strong>reset<\/strong>&gt;<br \/>\n<strong>chkconfig<\/strong> [<strong>&#8211;level<\/strong> <em>levels<\/em>] <em>name<\/em><\/p>\n<p>But when my friend use chkconfig there were error :<\/p>\n<p># chkconfig &#8211;levels 235 tomcat on<br \/>\nservice tomcat does not support chkconfig<\/p>\n<p>okay my friend ask me what is the 235 means , 235 is runlevel that the script starts.<br \/>\nFor instance, if we called this script \/etc\/init.d\/new-service and ran chkconfig new-service on, it would be active in runlevels 2,3 and 5.<\/p>\n<p>0-6 are runlevels. Typically for Redhat based distributions:<br \/>\n0 &#8211; Halt the system<br \/>\n1 &#8211; Single-user mode<br \/>\n2 &#8211; Multi-user mode (without networking)<br \/>\n3 &#8211; Multi-user mode<br \/>\n5 &#8211; Multi-user mode, graphical login<br \/>\n6 &#8211; Reboot the system<\/p>\n<p>you can check your service run level by using chkconfig &#8211;list:<\/p>\n<p># chkconfig &#8211;list<br \/>\ncourier-authlib\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\ncourier-imap\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\ncrond\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nhttpd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\niptables\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nldap\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0 \u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nlm_sensors\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nlsws\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:off\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nmcstrans\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nmessagebus\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nmysqld\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nnamed\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nnetconsole\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nnetfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nnetplugd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nnetwork\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0 4:on\u00a0\u00a0 5:on\u00a0\u00a0 6:off<br \/>\nportmap\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nrdisc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nrestorecond\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nsnmpd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nsnmptrapd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nsshd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nsyslog\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nwinbind\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:off\u00a0\u00a0 3:off\u00a0\u00a0 4:off\u00a0\u00a0 5:off\u00a0\u00a0 6:off<br \/>\nxinetd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0:off\u00a0\u00a0 1:off\u00a0\u00a0 2:on\u00a0\u00a0\u00a0 3:on\u00a0\u00a0\u00a0 4:on\u00a0\u00a0\u00a0 5:on\u00a0\u00a0\u00a0 6:off<br \/>\nabout the service tomcat does not support chkconfig error , after some searching it turn&#8217;s out. In order to support chkconfig, an init script must:<br \/>\n1.\u00a0 Be located in \/etc\/rc.d\/init.d (which \/etc\/init.d is a symlink to)<br \/>\n2.\u00a0 Have a commented out line that contains &#8220;chkconfig: &lt;default\u00a0 runlevels for this service&gt; &lt;start priority&gt; &lt;stop priority&gt;&#8221;<br \/>\n3.\u00a0 Have a commented out line that contains &#8220;description: &lt;a description of the service&gt;&#8221;<br \/>\n4.\u00a0 Upon successful service startup, place a lock file in\u00a0 \/var\/lock\/subsys that matches the name of the service script.\u00a0 Upon\u00a0 successful service shutdown, the lockfile must be removed.<\/p>\n<p>okay i ask my friend to add this on the tomcat script<br \/>\n#!\/bin\/sh<br \/>\n#<br \/>\n# Tomcat Server<br \/>\n#<br \/>\n# chkconfig: 345 96 30<br \/>\n# description: Java servlet container<\/p>\n<p>and after some reboot itis working \ud83d\ude42 , the tomcat script are executed on reboot time, here is the detail script<\/p>\n<p>#!\/bin\/sh<br \/>\n#<br \/>\n# Tomcat Server<br \/>\n#<br \/>\n# chkconfig: 345 96 30<br \/>\n# description: Java servlet container<\/p>\n<p>JAVA_HOME=\/opt\/jdk<\/p>\n<p>PATH=${JAVA_HOME}\/bin:${PATH}<\/p>\n<p>TOMCAT_START=\/opt\/tomcat\/bin\/startup.sh<\/p>\n<p>TOMCAT_STOP=\/opt\/tomcat\/bin\/shutdown.sh<\/p>\n<p>export JAVA_HOME PATH<\/p>\n<p>start()<br \/>\n{<br \/>\nif [ -x ${TOMCAT_START} ]; then<br \/>\necho &#8220;Starting tomcat server&#8230;&#8221;<br \/>\n${TOMCAT_START} &amp;<br \/>\nelse<br \/>\necho &#8220;Cannot start tomcat server&#8221;<br \/>\nfi<br \/>\n}<\/p>\n<p>stop()<br \/>\n{<br \/>\nif [ -x ${TOMCAT_STOP} ]; then<br \/>\necho &#8220;Stopping tomcat server&#8230;&#8221;<br \/>\n${TOMCAT_STOP} &amp;<br \/>\nelse<br \/>\necho &#8220;Cannot stop tomcat server&#8221;<br \/>\nfi<br \/>\n}<\/p>\n<p>restart()<br \/>\n{<br \/>\nstop<br \/>\nsleep 10<br \/>\nstart<br \/>\n}<\/p>\n<p>status()<br \/>\n{<br \/>\necho &#8220;No status available for tomcat server&#8221;<br \/>\n}<\/p>\n<p>case &#8220;$1&#8221; in<br \/>\n&#8216;start&#8217;)<br \/>\nstart<br \/>\n;;<br \/>\n&#8216;stop&#8217;)<br \/>\nstop<br \/>\n;;<br \/>\n&#8216;restart&#8217;)<br \/>\nrestart<br \/>\n;;<br \/>\n&#8216;status&#8217;)<br \/>\nstatus<br \/>\n;;<br \/>\n*)<br \/>\necho &#8220;Please supply an argument [start|stop|restart]&#8221;<br \/>\nesac<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just today one of my friend are pm me and ask how to make his tomcat service at \/etc\/init.d\/tomcat to run when the server reboot. At the first time i just tell him to use chkconfig because the os that he use was CentOS What is chkconfig ? Chkconfig is a basic system utility. It [&hellip;]<\/p>\n","protected":false},"author":386,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[487],"tags":[1891],"class_list":["post-362","post","type-post","status-publish","format-standard","hentry","category-centos","tag-redhat-run-level-and-how-to-make-tomcat-service-to-run-on-boot-time-in-centos"],"_links":{"self":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=362"}],"version-history":[{"count":2,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/362\/revisions"}],"predecessor-version":[{"id":514,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/362\/revisions\/514"}],"wp:attachment":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}