I have a Wolfram script that generates plots, and exports them by evaluating expressions of the form
Export["/path/to/some.svg", myPlot]; The script works as intended when I run it from the [Unix] command line. In particular, the plots get exported to files in valid SVG format, AND no windows ever pop up.
And yet, if I run the same script through a cron-initiated command, it fails at the first such Export expression, with the error
Can't open display: ":0.0"
I.e., the script seems to be requiring a graphic display, even though it is operating non-interactively.
Is there a way around this?
FWIW, for this I'm using Mathematica 11.0.1 (it's what's available in my current employer's system).
Also, FWIW, the script gets invoked with
wolframscript -script /path/to/my/script.m
I can reproduce the error from the command line by running
DISPLAY= wolframscript -script /path/to/my/script.m
BTW, the solution given in Wolfram Script Not Completing when ran as cron job does not apply to my case, since my script uses none of ConnectToFrontEnd, UseFrontEnd, CloseFrontEnd, etc. In fact, my script makes no explicit mention of a front end anywhere.
Exportfor some formats needs a frontend. Looks very much like SVG is among those formats, thus the error message. Thus I am pretty confident that your question is in fact a duplicate as Jason B. suggests... $\endgroup$