'Errors "QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-mizu'" when running phantomjs from contab

When I run phantomJS with crontab, the following errors occur. How can I run it successfully? I am using Ubuntu 17.10.

[error]

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 


Solution 1:[1]

"QStandardPaths: XDG_RUNTIME_DIR not set" isn't an error. Rather, it is a warning that you didn't specify this environment variable, so Qt is choosing its own location to set up shop. So long as it is writable (and it should be), that should be ok.

So, more likely the problem is "QXcbConnection: Could not connect to display". There's a similar bug at error: XDG_RUNTIME_DIR not set in the environment. Gtk-WARNING **: cannot open display: that suggests you may have a problem with carrying over environment variables.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eric Aya