方法一(rc.local)
由于在centos7中/etc/rc.d/rc.local的权限被降低了,所以需要赋予其可执行权
chmod +x /etc/rc.d/rc.local
赋予脚本可执行权限
假设/opt/script/autostart.sh是你的脚本路径,给予执行权限
chmod +x /opt/script/autostart.sh
打开/etc/rc.d/rc/local文件,在末尾增加如下内容
vi /etc/rc.d/rc.local
/opt/script/autostart.sh