简体   繁体   English

在CentOS上登录后如何启动应用程序?

[英]How to start application after login on CentOS?

I am trying to start GUI application with upstart script on CentOS. 我正在尝试使用CentOS上的upstart脚本启动GUI应用程序。 I have test script located /etc/init/ folder. 我的测试脚本位于/ etc / init /文件夹中。

start on desktop-session-start
stop on desktop-shutdown

respawn

script
export DISPLAY=:0
sleep 5
exec /.1/Projects/UpstartTest/start.sh &

end script

start.sh scripts is running binary files for GUI application. start.sh脚本正在运行GUI应用程序的二进制文件。

After reboot my computer. 重新启动我的计算机后。 When I typed: 当我输入时:

[root@mg-CentOS ~]# initctl status test
test stop/waiting

So my upstart is not runnig. 因此,我的暴发户不是流氓。 When i type 当我键入

initctl start test

manually it works fine without any problem. 手动它可以正常工作,没有任何问题。

How can I run this upstart script after user login (desktop started) ? 用户登录(桌面启动)后如何运行该新贵脚本? I am trying to find detailed documents for CentOS for upstart but there is no. 我正在尝试查找有关CentOS的详细文档,但没有。

For this purpose, you can use the update-rc tool, which is builtin on linux distributions. 为此,您可以使用在Linux发行版中内置的update-rc工具。 It basically creates a symbolic link for the script you want to be executed at startup, or some other OS states, on the folder rc.X, where X is the number of the folder that determines a state that you want. 它基本上在文件夹rc.X上为要在启动时执行的脚本或其他某些OS状态创建符号链接,其中X是确定所需状态的文件夹的编号。

You may want to have a look at this answer: Update-rc.d custom script running too late, and also runs at shutdown 您可能需要看看以下答案: Update-rc.d自定义脚本运行得太晚了,并且在关机时也运行

More information about can be found here: http://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts 有关更多信息,请参见: http : //www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts

Detailed information about the CentOS booting process can be found here: https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-boot-init-shutdown-process.html ; 有关CentOS引导过程的详细信息可以在这里找到: https : //www.centos.org/docs/5/html/Installation_Guide-zh-CN/s1-boot-init-shutdown-process.html ; the rc is being explained at this document as well. rc也在本文档中进行了说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM