Linux self-booting method

Source: Internet
Author: User

Reference article: http://vod.sjtu.edu.cn/help/Article_Print.asp?ArticleID=626

http://hiandroidstudio.blog.51cto.com/5902332/1308341

http://blog.csdn.net/fireroll/article/details/15503463

To see if the service is self-booting

View the current status of a service

#service ServiceName status

View the start-up status of a service

#chkconfig--list ServiceName

I. Adding in/etc/rc.local

If you do not want to glue the script, or create a link or something, then:

Step1. First, modify the script so that all its modules can be executed when any directory is started;

Step2. Add a row at the end of/etc/rc.local to start the script with an absolute path;

In Tomcat, for example, increase the startup script path in/etc/rc.d/rc.local, for example:

Export JDK_HOME=/USR/LOCAL/JDK

Export JAVA_HOME=/USR/LOCAL/JDK

/apache/tomcat/bin/start.sh

If Jdk_home and Java_home are already configured in the system, only the last line of Tomcat commands is required

Two. Chkconfig command (under Redhat OS)

The chkconfig has five functions:

Add services, delete services, list services, change startup information, and check the startup status of a particular service.

The syntax is:

Chkconfig--list [Name]

Chkconfig--add Name

Chkconfig--del Name

Chkconfig [--level levels] Name

Chkconfig [--level levels] Name


For example:

1. Enter/ETC/INIT.D;

2. Create a new file tomcat with the following contents:

#!/bin/sh# chkconfig:345 99 10# Description:auto-starts tomcat#/etc/init.d/tomcat# Tomcat Auto-start# Source function library.#./etc/init.d/functions# source Networking configuration.#./etc/sysconfig/Networkretval=0Export Jre_home=/usr/java/jdk1.6. 0_29export Catalina_home=/usr/local/Tomcatexport catalina_base=/usr/local/Tomcatstart () {if[-F $CATALINA _home/bin/startup.sh];thenecho $"Starting Tomcat"$CATALINA _home/bin/Startup.shretval=$?Echo"OK"return$RETVALfi}stop () {if[-F $CATALINA _home/bin/shutdown.sh];thenecho $"Stopping Tomcat"$CATALINA _home/bin/Shutdown.shretval=$?Sleep1PS aux| Grep/usr/local/tomcat | awk '!/awk/&&!/grep/{print $ |xargs} ' kill-9Echo"OK"# [$RETVAL-eq 0] && rm-f/var/lock/...return$RETVALfi} Case"$"Instart) Start; stop) stop;; Restart) echo $"Restaring Tomcat"$0Stopsleep1$0start;;*) echo $"Usage: $ {Start|stop|restart}"Exit1;; Esacexit $RETVAL

3. Add Execute Permissions

chmod +x/etc/init.d/tomcat

4. Boot with System

Chkconfig--add Tomcat

5. Rebooting the system

Linux self-booting method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.