MathGroup Archive 2010

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

Search the Archive

Launch kernel and packages from Mac OS's launchd utility

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111950] Launch kernel and packages from Mac OS's launchd utility
  • From: Garapata <warsaw95826 at mypacks.net>
  • Date: Sat, 21 Aug 2010 04:17:48 -0400 (EDT)

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.

(See:
http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_frm/thread/6e781c5e0c770fbc/9fb5f9ba198e87ea?lnk=gst&q=Garapata#9fb5f9ba198e87ea)

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

/Applications/Mathematica.app/Contents/MacOS/MathKernel -run "<</
Path.../myAutoRun.m"

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
cron.
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
 http://www.apple.com/DTDs/PropertyList-1.0.dtd >
 <plist version="1.0">
 <dict>
<key>Label</key>
<string>myAutoRun test</string>
<key>Program</key>
<string>//Applications/Mathematica.app/Contents/MacOS/MathKernel</
string>
<key>ProgramArguments</key>
<array>
<string>MathKernel</string>
<string>  -run </string>
<string>  "<</path/myAutoRun.m"</string>
</array>
<key>StartIntervall</key>
 <integer>3600</integer>
 </dict>
 </plist>

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

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.

G


  • 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