我编写了名为/etc/systemd/system/mytest.service的服务文件。然后我想用一些在新终端控制台上打印的命令启动一个新的终端窗口。
文件 mytest.service 包含以下内容:
[Unit]
Description= Test
After= network.target
[Service]
ExecStart=/usr/bin/gnome-terminal -- "echo 'test' > /home/me/test.log; echo 'abcd';"
StandardOutput=journal+console
[Install]
WantedBy=default.target
运行sudo systemctl start mytest
并打印状态后,我收到以下错误消息:
Sep 23 21:09:50 ub20 gnome-terminal[4205]: Unable to init server: Could not connect: Connection refused
Sep 23 21:09:50 ub20 gnome-terminal[4205]: # Failed to parse arguments: Cannot open display:
Sep 23 21:09:50 ub20 systemd[1]: ethminer.service: Main process exited, code=exited, status=1/FAILURE
这里有什么问题?
systemctl --user enable mytest.service