求助Centos 7 开机不执行rc.local 服务

本人刚开始接触Centos系统,需要设置开机启动一个QT编译生成的程序。在CSDN中看到很多类似的方法,但是都解决不了我的问题。
目前已经将编写的脚本文件通过/etc/rc.d/rc.local来执行:
#!/bin/bash
touch /var/lock/subsys/local;
cd /home/ie/desktop/test
./test.sh &
exit 0
目前在终端中执行./rc.local可以正确执行/home/ie/desktop/test中的test.sh

但是对应的/usr/lib/systemd/system/rc-local.service总是处于以下状态:
[root@localhost rc.d]# systemctl status rc-local.service
● rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
Active: active (exited) (Result: exit-code) since Thu 2019-02-14 21:02:25 CST; 1h 58min ago
Main PID: 42953 (code=exited, status=1/FAILURE)
Tasks: 0
CGroup: /system.slice/rc-local.service

Feb 14 21:02:25 localhost.localdomain systemd[1]: Starting /etc/rc.d/rc.local Compatibility…
Feb 14 21:02:25 localhost.localdomain systemd[1]: Started /etc/rc.d/rc.local Compatibility.
Feb 14 21:02:25 localhost.localdomain rc.local[42950]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’
Feb 14 21:02:25 localhost.localdomain rc.local[42950]: qt.qpa.screen: QXcbConnection: Could not connect to display
Feb 14 21:02:25 localhost.localdomain rc.local[42950]: Could not connect to any X display.
Feb 14 21:02:25 localhost.localdomain systemd[1]: rc-local.service: main process exited, code=exited, status=1/FAILURE

望曾遇到类似问题的朋友来帮忙解决!

1个回答

besthgt
besthgt 谢谢,终于发现问题不是rc.local不执行的问题了,而是localhost.localdomain rc.local[15230]: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’ localhost.localdomain rc.local[15230]: qt.qpa.screen: QXcbConnection: Could not connect to display localhost.localdomain rc.local[15230]: Could not connect to any X display.您有解决方法吗?
一年多之前 回复
besthgt
besthgt 回复ColdXmas: 目前已经知道开机执行rc.local文件了,问题在于QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’
一年多之前 回复
besthgt
besthgt 回复tcpdump2015: 谢谢,目前已经知道开机执行rc.local文件了,问题在于QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’
一年多之前 回复
qq_38194523
ColdXmas 为啥不写到/home/user/.bashrc里面 /root/.bashrc
一年多之前 回复
tcpdump2015
tcpdump2015 chmod +x /etc/rc.d/rc.local
一年多之前 回复
besthgt
besthgt 谢谢您的建议,我已经尝试过这个方法了,不行呀
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐