注册一个系统服务,开机自启动.
1. 脚本编写
#vim test.sh
在里面写上你自己的shell命令
2. 注册服务
复制代码代码如下:
# chmod 700 test.sh
# cp test.sh /etc/init.d/
# chkconfig --add test.sh
# chkconfig --list
(如果出现service do not support chkconfig,在脚本最前面加两行
#chkconfig: - 85 15
#description: nginx is a World Wide Web server. It is used to serve
即可
)
3.删除服务
复制代码代码如下:
# chkconfig --del test.sh
4. 开机自启
chkconfig test.sh on