Page tree
Skip to end of metadata
Go to start of metadata

i2S-6UB核心板上的Linux系统支持添加自定义应用,在系统启动后自动启动自定义的应用。

添加自定义的应用在/etc/rc.local文件中,文件内容如下:

root@i2c6ulxbe:~# cat /etc/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


这里以example.sh脚本应用为例,添加到自启动文件中

#!/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.
/home/root/example.sh &
exit 0


example.sh脚本应用的内容是每隔1s写入log文件,这样就可以通过查看log来确认,应用是否正常运行。内容如下:

#!/bin/sh

while true
do

echo "`date`" >> /home/root/example.log
sleep 1
done


修改后重新启动,ps可以看到example.sh应用己经启动了,使用tail命令可以看到example.log文件每隔一秒有时间数据在写入,说明自启动应用配置成功。

root@i2c6ulxbe:~# ps | grep example
  515 root      2760 S    {example.sh} /bin/sh /home/root/example.sh
  620 root      2904 S    grep example
root@i2c6ulxbe:~# tail -f example.log
Wed Mar  6 07:31:23 UTC 2019
Wed Mar  6 07:31:24 UTC 2019
Wed Mar  6 07:31:25 UTC 2019
Wed Mar  6 07:31:26 UTC 2019
Wed Mar  6 07:31:27 UTC 2019
Wed Mar  6 07:31:28 UTC 2019
Wed Mar  6 07:31:29 UTC 2019
Wed Mar  6 07:31:30 UTC 2019
Wed Mar  6 07:31:31 UTC 2019
Wed Mar  6 07:31:33 UTC 2019
Wed Mar  6 07:31:34 UTC 2019


  • No labels
Write a comment…