如果想要開機運行某程序,需要在開發板上編輯"/etc/rc.local"文件,在此文件添加你想開機運行的命令即可。這里給大家做一個示范,我們的需求是開機自啟動 hello.sh 腳本,并且打印 hello ! nice to meet you! 1. 首先啟動 ITOP-3399 開發板,開發板里面燒寫 Debian 系統,啟動開發板如下圖所示: ![]() 2. 我們要運行一個 hello.sh 的腳本,首先要寫一個腳本,腳本保存在開發板的/mnt 目錄下,腳本內容如下: echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" echo "hello ! nice to meet you!" 3. 腳本寫完,我們一定要執行 chmod 777 hello.sh 命令,賦予腳本權限,否則,不能運行程序。注意!一定要賦予開機運行的程序權限,否則不會開機啟動。 ![]() 4. 然后我們編輯開發板上的"/etc/init.d/rcS"文件,在里面添加你想開機運行的命令。輸入命令: vi /etc/init.d/rcS 我們想要開機自啟動 hello.sh 腳本,所以我們在/etc/init.d/rcS 文件中添加如下命令: cd /mnt && ./hello.sh 添加完保存退出,如下圖所示: ![]() 5. 重新啟動開發板,發現打印信息如下,開發板成功自啟動運行 hello.sh,并且打印 hello ! nice to meetyou! ![]() 迅為ITOP3399開發板 ![]() |