10
$\begingroup$

I run Mathematica on an iMac running OS X 10.6.8.

I have set the OS's "Launch Items" to include Mathematica so that the application opens when the computer boots.

Now I want to go further and set Mathematica to launch a specific notebook on startup.

Note: this note book has initialization cells so it will evaluate automatically. All of this goes to my ongoing automation of a variety of processes to run while I take a few days of vacation (IF I can get this working ;-)

I've searched Mathematica's "Preferences" and "Options", but haven't found anything to identify or set a specific notebook to launch when Mathematica starts.

If someone knows a way to do this that I haven't seen in these, please advise.

The following link to an old StackOverflow question, mathematica start front end and eval notebook from command line looks like it provides a way to do what I want to do, but on a Windows OS.

As I think about applying or translating this idea to my iMac, it seems like rather than having Mathematica as a "Launch Item", I have a couple of other possibilities:

  • setup a shell script using something like OS X's launchD to launch Mathematica and a specific notebook OR
  • use MathematicaScript to launch just the kernel and run the code currently in the desired notebook.

Neither of these are strong points. Can anyone recommend a way to do this or on Mac OS X 10.6.8 or some specific references that would help me learn what I need to do?


A bit of a footnote for some additional context. The notebook I need to run launches parallel kernels on a couple of servers. I've chosen this path of getting all of this to run on the machines' startup rather than putting all of this on a timer or even logging on remotely to run them because, I've found that (at least for now) restarting both Mathematica on the client machine and as parallel kernels on the servers just runs more reliably. It particularly avoids problems with kernels that haven't launched or some of which have shut down.

The Mac OS has a very reliable method to launch and shutdown the machines at specific times. As I need the code in the notebook to run at specific times this seems like a good thing on which to layer the other functionality.

$\endgroup$

1 Answer 1

14
$\begingroup$

You can use the global AutoOpenNotebooks setting to give a list of notebooks that must be opened on startup. The default path where it looks for these notebooks is $UserBasedirectory/SystemFiles/FrontEnd/TextResources.

enter image description here

Now every time you open Mathematica, that notebook will be opened (in my case, tile.nb).

$\endgroup$
6
  • $\begingroup$ Now you got me curious - what is tile.nb? Suspecting some mighty init mojo ;-) $\endgroup$
    – Yves Klett
    Jul 14, 2012 at 14:08
  • $\begingroup$ GREAT! That really puts my "vacation" mind at ease. This seems like the easiest possible solution to my remote launching needs. Thanks. $\endgroup$
    – Jagra
    Jul 14, 2012 at 14:09
  • $\begingroup$ @YvesKlett Ha, I wish. Those are some experiments for various background tiles for this site's design. One of them was this one. I just added the first notebook that I saw to the list above for illustration purposes $\endgroup$
    – rm -rf
    Jul 14, 2012 at 14:14
  • 2
    $\begingroup$ @YvesKlett All that is in Hypnotoad.nb $\endgroup$
    – rm -rf
    Jul 14, 2012 at 14:26
  • 2
    $\begingroup$ This raises the issue as to whether the Global Preferences might be extended (by Wolfram) so as include an item AutoLoadPackages that would automatically load specified packages on kernel start. I would find using such an option far more convenient than having to edit the kernel init.m or to move packages into Autoload. $\endgroup$
    – murray
    Jul 14, 2012 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.