当我使用crontab运行phantomJS时,会发生以下错误。我怎样才能成功运行它?我正在使用Ubuntu 17.10。
[错误]
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-mizu'
QXcbConnection: Could not connect to display
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Aborted (core dumped)
[crontab的]
*/1 * * * * /home/mizu/phantomjs /home/mizu/script.js
“QStandardPaths:XDG_RUNTIME_DIR未设置”不是错误。相反,它是一个警告,你没有指定这个环境变量,所以Qt选择自己的位置来设置商店。只要它是可写的(它应该是),那应该没问题。
因此,问题更可能是“QXcbConnection:无法连接到显示”。在error: XDG_RUNTIME_DIR not set in the environment. Gtk-WARNING **: cannot open display:上有一个类似的错误,暗示你可能在携带环境变量时遇到问题。