ubuntu服务器设置启动项

2017-03-31  本文已影响18人  戏之地

使用/etc/rc.local

无效原因

ubuntu没有RH系列中的chkconfig命令
/etc/rc.local中进行配置无用.
ubuntu默认的/bin/shdash,而/etc/rc.local用的是/bin/sh,故不能使用.

解决方法

推荐第二种

sudo rm /bin/sh
sudo ln -s /bin/bash /bin/sh

如果你做了这样的更改,可能依然无用.执行这个文件默认没有PATH
需要指定绝对路径

/etc/rc3.d中增加一个启动脚本

注意使用绝对路径

更新/etc/init.d/

$ sudo chmod 755 /etc/init.d/test
$ cd /etc/init.d
$ sudo update-rc.d test defaults 95
$ cd /etc/init.d
$ sudo update-rc.d -f test remove
上一篇 下一篇

猜你喜欢

热点阅读