besthgt
besthgt
2019-02-14 23:25
采纳率: 0%
浏览 2.2k

求助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条回答 默认 最新

相关推荐