Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Launch kernel and packages from Mac OS's launchd utility

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111989] Re: Launch kernel and packages from Mac OS's launchd utility
  • From: peter <plindsay.0 at gmail.com>
  • Date: Mon, 23 Aug 2010 02:39:59 -0400 (EDT)

Not sure this helps but if you want to run a shell script at regular
intervals I'd use the free mac utility Lingon if you're running
Leopard / Snow Leopard.

Peter

On 21 August 2010 09:17, Garapata <warsaw95826 at mypacks.net> wrote:
> 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: Re: Launch kernel and packages from Mac OS's launchd utility
  • Next by Date: Re: Proper style for argument checking?
  • Previous by thread: Re: Launch kernel and packages from Mac OS's launchd utility
  • Next by thread: Centering Graphical Output