gpt4 book ai didi

linux - CentOS登录后如何启动应用程序?

转载 作者:太空宇宙 更新时间:2023-11-04 03:54:44 25 4
gpt4 key购买 nike

我正在尝试在 CentOS 上使用 upstart 脚本启动 GUI 应用程序。我的测试脚本位于/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 脚本正在运行 GUI 应用程序的二进制文件。

重新启动计算机后。当我输入:

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

所以我的 Upstart 没有运行。当我输入时

initctl start test

手动它可以正常工作,没有任何问题。

如何在用户登录(桌面启动)后运行这个 Upstart 脚本?我正在尝试为 Upstart 找到 CentOS 的详细文档,但没有。

最佳答案

为此,您可以使用 update-rc 工具,该工具内置于 Linux 发行版中。它基本上为您想要在启动时执行的脚本或其他一些操作系统状态在文件夹 rc.X 上创建一个符号链接(symbolic link),其中 X 是确定您想要的状态的文件夹编号。

您可能想看看这个答案:Update-rc.d custom script running too late, and also runs at shutdown

更多信息可以在这里找到: http://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts

有关 CentOS 启动过程的详细信息可以在这里找到:https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-boot-init-shutdown-process.html ;本文档中也对 rc 进行了解释。

关于linux - CentOS登录后如何启动应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25162751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com