Linux Ubuntu (16.04.10) 开机自启动脚步,/etc/rc.local 中命令不执行

Itgo · 2019年06月06日 · 最后由 fangxing204 回复于 2019年06月09日 · 6619 次阅读

/etc/rc.local 文件内容如下

#!/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.

#sleep 3
#source /etc/profile
touch /home/demo/yyyyy.log

exit 0

試試看,chmod 755 /etc/rc.local

总结下碰到的原因:

1、如 1 楼所说没有加 x 权限

2、脚本内异常,第一行 -e 参数,如果有异常即终止后续操作

3、某些情况下 bash,dash,sh 的问题,(网上搜的)

4、这次的问题是,rc.local 执行在先,mount 命令在后,导致服务没有启动。不是楼主装的环境,所以搞了好久。

钟馗镇楼

确定 rc.local 服务运行正常, systemctl status rc.local

需要 登录 后方可回复, 如果你还没有账号请 注册新账号