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