1

I have to run a notebook (to get data of a data warehouse) every day. Currently I start it manually. So, on the weekend, I don't get the data. That's why I'm looking for a solution to run the notebook everyday automaticly.

  • For future Mathematica-related questions, you can consider asking on [Mathematica.SE](http://mathematica.stackexchange.com/). Most of the Mathematica-related activity has moved there. – Szabolcs May 11 '12 at 07:35

2 Answers2

2

If on UNIX-like OS's, you can convert the notebook's content into a Mathematica script and schedule it to run periodically using cron.

Another less recommendable way is to do the scheduling in Mathematica. Something like:

Do[
    If[
        MemberQ[{"Monday", ...}, DateString["DayName"]], 
        runMyProgram[]
    ]; 
    Pause[3600*24],
    {30}
]
Meng Lu
  • 13,726
  • 12
  • 39
  • 47
  • 1
    The proper way to do scheduling in Mathematica is `CreateScheduledTask` for version 8. For version 7, there's [very similar undocumented functionality](http://mathematica.stackexchange.com/questions/2806/internal-periodical-functions-in-version-7). – Szabolcs May 11 '12 at 07:33
  • I would like to try the CreateScheduledTask way? But I have hardly any experience with Mathematica, so how would the code, to run a notebook every day, look like. Thanks – user1387667 May 11 '12 at 09:26
1

If you just need to run Mathematica and write output you can use the following procedure and call it with a Windows scheduled task (set to 'daily'). Some of the file locations in the example are specified for simplicity, i.e. one is in the Mathematica directory itself, but needn't necessarily be with further path detail added, (system depended).

mathematica start front end and eval notebook from command line

If your notebooks are designed to run interactively and save their contents within the same notebook you can use the methods in the following post, the more simple of which has the harmless side-effect of generating an 'uncaught throw' warning, (the cause of which is explained in the post).

Uncaught Throw generated by JLink or UseFrontEnd

Community
  • 1
  • 1
Chris Degnen
  • 8,443
  • 2
  • 23
  • 40