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