方法一:修改rc.local
1、因為在centos7中/etc/rc.d/rc.local的權限被降低了,所以需要賦予其可執行權
chmod +x /etc/rc.d/rc.local
2、賦予腳本可執行權限
假設/usr/local/script/autostart.sh是你的腳本路徑,給予執行權限
chmod +x /usr/local/script/autostart.sh
3、打開/etc/rc.d/rc.local文件,在末尾增加如下內容
/usr/local/script/autostart.sh