How does one add auto-start to a program in Linux?

Source: Internet
Author: User

I want to make my serviceProgramIt is automatically started after the system is restarted. A script is used to start my service.
There are two methods:

Method 1:

Sudo VI/etc/init. d/rc. Local
Add the script command to start the service.

The advantage of this method is that the user is not logged on yet, and the Su is used to start the service. It is equivalent to sudo. Huge permissions.
The defect of this method is: At this time, the user has not yet logged in, of course, the user's main directory is not specified, so if our service program is useful '~ 'As the path, it will be discarded ,'~ 'Indicates 'null '...
PS: logs can be viewed in/var/log/boot. log.

Method 2:

Sudo VI/etc/profile
Add the script command to start the service at the bottom.

This method has the following advantages: logged-on users, specifying the main directory and shell used, and setting various environment variables. Then you can use '~ 'Specifies the main directory.
The disadvantage of this method is that the permission is the same as that of the current user. If it is a common user, The sudo command will be discarded, and the startup script will not allow you to enter the password for interaction.

References:
1. http://hi.baidu.com/youdianweidao/blog/item/b3ef79ecb197e42e62d09fdb.html
2. http://blog.csdn.net/unbutun/article/details/3847514

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.