Linux添加开机自启动一般是在 /etc/rc.local 文件里添加相应的命令,但是新版的 ubuntu 没有 rc.local 文件,没有关系,我们可以自己添加一个,比如在 /root 目录下,有一个 test.sh 是需要开机自启动的,vi /etc/rc.local 添加内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#!/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. cd /root/ nohup /root/test.sh & |
保存之后,不要忘记给 rc.local 添加可执行权限
chmod +x /etc/rc.local
转载请注明:exchen's blog » 解决ubuntu没有rc.local文件