https://ubuntuforums.org/showthread.php?t=2327011

1、方法一,编辑rc.loacl脚本

Ubuntu开机之后会执行/etc/rc.local文件中的脚本,
所以我们可以直接在/etc/rc.local中添加启动脚本。
当然要添加到语句:exit 0 前面才行。
如:

复制代码
代码如下:
sudo vi /etc/rc.local


然后在 exit 0 前面添加好脚本代码。

 

2、方法二,添加一个Ubuntu的开机启动服务。

如果要添加为开机启动执行的脚本文件,
可先将脚本复制或者软连接到/etc/init.d/目录下,
然后用:update-rc.d xxx defaults NN命令(NN为启动顺序),
将脚本添加到初始化执行的队列中去。
注意如果脚本需要用到网络,则NN需设置一个比较大的数字,如99。
1) 将你的启动脚本复制到 /etc/init.d目录下
 以下假设你的脚本文件名为 test。
2) 设置脚本文件的权限

复制代码
代码如下:
$ sudo chmod 755 /etc/init.d/test


3) 执行如下命令将脚本放到启动脚本中去:

复制代码
代码如下:
$ cd /etc/init.d
$ sudo update-rc.d test defaults 95


 注:其中数字95是脚本启动的顺序号,按照自己的需要相应修改即可。在你有多个启动脚本,而它们之间又有先后启动的依赖关系时你就知道这个数字的具体作用了。该命令的输出信息参考如下:

复制代码
代码如下:
update-rc.d: warning: /etc/init.d/test missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for /etc/init.d/test ...
/etc/rc0.d/K95test -> ../init.d/test
/etc/rc1.d/K95test -> ../init.d/test
/etc/rc6.d/K95test -> ../init.d/test
/etc/rc2.d/S95test -> ../init.d/test
/etc/rc3.d/S95test -> ../init.d/test
/etc/rc4.d/S95test -> ../init.d/test
/etc/rc5.d/S95test -> ../init.d/test


卸载启动脚本的方法:

复制代码
代码如下:
$ cd /etc/init.d
$ sudo update-rc.d -f test remove


命令输出的信息参考如下:

复制代码
代码如下:
Removing any system startup links for /etc/init.d/test ...
/etc/rc0.d/K95test
/etc/rc1.d/K95test
/etc/rc2.d/S95test
/etc/rc3.d/S95test
/etc/rc4.d/S95test
/etc/rc5.d/S95test
/etc/rc6.d/K95test

-------------------------------------------------------------------------------------------------

Re: insserv: warning: script 'lampp' missing LSB tags and overrides

insserv: warning: script 'lampp' missing LSB tags and overrides Originally Posted by sreez insserv: warning: script 'lampp' missing LSB tags and overrides
Iam using ubuntu 16.04 server while adding lampp service to automatic startup on the boot sudo update-rc.d lampp defaults. Its shows the error insserv: warning: script 'lampp' missing LSB tags and overrides insserv: There is a loop between service monit and lampp if stopped insserv: loop involving service lampp at depth 2 insserv: loop involving service monit at depth 1 insserv: Stopping lampp depends on monit and therefore on system facility `$all' which can not be true! insserv: exiting now without changing boot order! update-rc.d: error: insserv rejected the script header plz help to fix it. thanks in advance.
have same issue and fix this with edit lampp script
Code:
#!/bin/bash
### BEGIN INIT INFO
# Provides: lampp
# Required-Start:    $local_fs $syslog $remote_fs dbus
# Required-Stop:     $local_fs $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start lampp
### END INIT INFO
/opt/lampp/lampp start

相关文章:

  • 2022-01-01
  • 2021-07-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-10-22
  • 2021-11-12
  • 2021-04-15
相关资源
相似解决方案