如果想要开机运行某程序,需要在开发板上编辑"/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开发板

|