ubuntu没有rc.local文件----ubuntu怎样设置开机启动项

说明:ubuntu从16.10就没有rc.local这个文件了,自己创建就可以

root@v2ray-tw:~# touch /etc/rc.local 

增加可执行权限

root@v2ray-tw:~# chmod a+x /etc/rc.local

编写文件,在exit 0之前加入需要执行的语句即可。

注意:不要加入死循环的执行语句,如果已经发生系统无法系统可以进单用户模式进行操作。

 #!/bin/sh -e
  
 # rc.local
 #
 # This script is executed at the end of each multiuser runlevel.
 # Make sure that the script will "exit 0" on success or any other
 # value on error.
 #
 # In order to enable or disable this script just change the execution
 # bits.
 #
 # By default this script does nothing.
 docker start centos-bt
 docker start centos7-v2ray
 exit 0

如上为我加入的docker容器开机启动

发表评论

后才能评论