MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Launch kernel and packages from Mac OS's launchd utility

This question follows up on an earlier one where I needed to find out
how to launch the Mathematica kernel and a package from the command
line on a Mac.


The required syntax for the command line looks something like this:

/Applications/ -run "<</

myAutoRun.m has initialized cells that do some stuff and then quit the
kernel.  Works fine.

For my next step, I'd like to run the kernel and myAutoRun.m from a
Mac's "launchd" utility and set it up to launch and run the package at
specific intervals automatically without further human participation.
Apple created launched to integrate a bunch of UNIX utilities like
Ostensibly, one can use it to launch daemons, process, and programs
from a launchd "property list", basically an XML file that the system
runs at startup.
So, following Apple's documentation something like this ought to work:

  <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN >
 <plist version="1.0">
<string>myAutoRun test</string>
<string>  -run </string>
<string>  "<</path/myAutoRun.m"</string>

The stuff between  <dict> and  </dict> does the specific work.
The section:
<string>  -run </string>
<string>  "<</path/myAutoRun.m"</string>

identifies what to run (apparently, with launchd one can't put the
entire command on a single line like you can from a cmd prompt, hence
the array).

and finally the StartInterval section should launch the kernel and run
the package every 3600 seconds (each hour)

Looks good in theory, but it seems launchd doesn't know what to do
with the Mathematica command:

<string>  "<</path/myAutoRun.m"</string>

following the -run option.

I've started trying to use:

-initfile " file"

which the documentation mentions, but doesn't discuss in detail (that
I've found).  I think it should "execute the  commands in the
initialization file, ' file'  during startup".

Sorry for the long winded explanation.

Now,  a number of questions.

Can I get launchd to launch the kernel and run the package?
How do I do it?
Does a better approach exist?

If anyone can offer general insight or guidelines for auto running
packages and the issues involved, that would help a lot.

Thanks to all.


  • Prev by Date: Extracting eigenvectors of symbolic matrices
  • Next by Date: Re: Equation style crash bug
  • Previous by thread: Extracting eigenvectors of symbolic matrices
  • Next by thread: Re: Launch kernel and packages from Mac OS's launchd utility