OKA6818 Linux + Qt5 应用程序的开机自启动
1,编写Qt5应用程序QtApp并且远程调试成功。
2,利用XShell远程登陆后可在命令行输入命令/qt/QtApp启动成功
3,使用如下方法可以开机自动运行
- 在/etc/profile最后添加(
注
1)
/qt/QtApp
- 在/etc/inittab种找到
console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
注释,并添加一行
::respawn:-bin/sh
(注
2)
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id == tty to run on, or empty for /dev/console
# runlevels == ignored
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run
# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/bin/mount -a
::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS
# Put a getty on the serial port
#console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
::respawn:-bin/sh
# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
- 重新启动,开机自动运行成功
后记20191202:
用以上的方法,因为/etc/profile只要用ssh或者超级终端登陆一次就会执行一次,所以一旦有多个终端登陆,QtApp也会执行多次。
将/etc/profile最后添加的 /qt/QtApp 删除,然后再rsC最后添加:
source /etc/profile
/qt/QtApp &
这样就真正实现了开机启动一次的效果了。