Message Boards Message Boards

0
|
8589 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Execute wolfram as cron job

Hi,

I made Mathematica script that could be executed on RPI by:
$ wolfram -script ./script_name.m
and it does what I wish. But if I try to execute it from cron job:
27 * * * * sudo wolfram -noprompt -script /home/user/path/script_name.m > cron_log.txt
with or with out sudo and -noprompt, all I get is entry into cron_log.txt:

Developer`LaunchFrontEnd::nxsrv: An x server is required for that operation.

Rasterize::nofe: A front end is not available; Rasterize requires a front end.
$Failed

Developer`LaunchFrontEnd::nxsrv: An x server is required for that operation.
Rasterize::nofe: A front end is not available; Rasterize requires a front end.
$Failed

Script is txt file and uses Import, DateListPlot, and Export command to save plot as PNG.

Any idea why and how...
POSTED BY: Zoran Grujic
4 Replies
=============================Updated=========================
If Rasterize is essential in your application, you may need to include this line in the code. Sometimes you also have to include the Java graphics package in the kernel command so you can export graphics object like what can be done with FrontEnd (by default, the graphics is exported to $HomeDirectory ): 
<<JavaGraphics`
Export["test.jpg",Rasterize[1]]

This link shows an application of the lines above. 
POSTED BY: Shenghui Yang
I'm assuming your script uses Rasterize indirectly through the Export command.  Do you still get the error if you don't Export?
POSTED BY: BoB LeSuer
@ BoB
No Export[] no error, but no useful result also.
POSTED BY: Zoran Grujic
@ Shenghui Yang
Could you write the code?
Something like:
Needs["JLink`"]
UseFrontEnd[Export[...]]
or not?
POSTED BY: Zoran Grujic
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract