<p>
1、方法一:利用upstart 工具
cd /etc/init
ls
显示如下图:
新建一个xxx.conf
内容如下:
root@developer-Host:/etc/init# cat xxx.conf
# auto-serial-console - autostarts getty on serial console
#
# This service maintains a getty on serial port given as 'console' kernel argument.
#
# Last 'console' argument is used
#
description "xxzta"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
umask 022
console output
chdir /opt/qx_v2.0/bin //你的程序存放位置
exec ./test //你的程序名称
新建保存后,
upstart xxx //程序开启
upstop xxx //程序关闭
upstart 命令的介绍参考:upstart工作原理的介绍