How Linux adds self-booting to Programs

Source: Internet
Author: User

I want my service program to start automatically after rebooting the system. A script was used to start my service.
There are now two methods:

Act 1:

sudo vi/etc/init.d/rc.local
Add a script command to start the service here.

The advantage of this method is that the user is not logged in at this time, and the start service is SU. Equivalent to sudo. The privilege is extremely large.
The flaw of this method is: This time the user has not login, of course, not specified with the home directory, so if our service program useful to ' ~ ' as the path, then waste, ' ~ ' means ' null ' ...
PS: You can read the log in/var/log/boot.log.

Act 2:

sudo vi/etc/profile
At the bottom, add the script command to start the service.

The advantage of this method is that the logged-in user specifies what the home directory is, what shell to use, and so on, and sets up various environment variables. Then you can use ' ~ ' to specify the home directory.
The flaw with this method is that the permissions are the same as the current user. If it is a normal user, the sudo command is obsolete, and this startup script will not give you the interaction to enter the password.

Resources:
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.