问题描述:在rc.local 添加了执行脚本,但是系统启动后,脚本没有执行。
解决方案:
1. 给rc.local 添加可执行权限
sudo chmod 755 /etc/rc.local
注意:不能是777
2. 确保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.
exit 0
确保第一行是:
#!/bin/sh -e
或
#!/bin/bash
第一行前面不能有空行,空格。