Linux enables a program to start automatically and add a program as a service.

Source: Internet
Author: User

Linux enables a program to start automatically and add a program as a service.

This article takes tomcat7 as an example.

First, find the tomcat startup directory. My directory is cd/usr/local/tomcat7/bin /.

The startup script is startup. sh.

Add the tomcat STARTUP script in the/etc/rc. d/rc. local file.

Restart the operating system and find that Tomcat 7 can be started automatically.

 

Add tomcat as a service

Copy the/usr/local/tomcat7/bin/catalina. sh file to the/etc/rc. d/init. d directory and rename it tomcat.

Run the command cp/usr/local/tomcat7/bin/catalina. sh tomact/etc/rd. d/init. d/tomcat

Open the copied tomcat File

Add the following

These two sentences must be added, or an error will be reported later. Http:// I .cnblogs.com/EditPosts.aspx? Postid = 3897603 & update = 1

The first line is service configuration: the first number is the service running level, 2345 indicates that the Service running level is 2, 3, 4, and 5 (Linux running level is 0 to 6); the second number is the startup priority, the value ranges from 0 to 99; the third number is the stop priority, and the value ranges from 0 to 99.
The second line is the description of the service.

Add

Save the file.

Run the command chkconfig -- add tomcat. If service tomcat does not support chkconfig appears. Possible cause: first, the catalina. sh file is not copied to the/etc/rc. d/init. d/file and renamed tomcat.

Cause 2: Not added at the beginning of the tomcat File

Run the command chkconfig -- add tomcat

Chkconfig -- list

Tomcat is displayed.

Or you can directly chkconfig -- list tomcat.

 


In linux, how does one enable a program? For example, a simple hello world! How can I enable the program to start automatically under Linux?

Put executable files
/Etc/rc. d/init. d/file name

Then
Chkconfig -- add file name

Then
Chkconfig on file name

Whether the chkconfig and rclocal change methods can coexist when the linux setup program is started automatically

Top of your lungs, it's very dish at first glance, even more than me.
The services called by chkconfig are under/etc/init. d, and these are all started.
The/etc/rc. d/rc. local file is read after the system initialization is complete. The stuff in this stuff has little to do with whether the system is started.
Of course rc. the local ghost seems to be available only under the Red Hat. In other operating systems, to automatically start an additional Dongdong, you can only run the script in/etc/init. d, and then soft link to the corresponding startup level directory.

Related Article

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.