Running Mathematica (or other computations) in background
Thursday, April 23rd, 2009From time to time (unfortunately) I want/have to run long Mathematica calculations. Since my office machine is quite strong (or at least faster than my machine), I want to do the computation on that machine. To start a background Mathematica calculation on Linux machines do the following: First log in to your machine using ssh. Then start “screen”. “screen” will enable you to log-off even when the calculation is running. Thus, this works for any kind of computations (I think there is another Linux trick to do this, but I don’t remember). If you’re using Linux everyday, it’s worth to learn how to use “screen”. Your efficiency will increase by a factor of 10^500.
Create a plain text file, say, with the name “calculation”. Enter everything you want to have done in this file. For example
A={{a,b},{c,d}}
B=Inverse[A]
DoVeryComplicatedThingWhichTakesAtLeast100HoursWith[A]
Then just run
math -run “<<calculation”
Then “detach” from the screen by entering Ctrl-a and then d, that is, first enter Ctrl-a, release and then enter d. Now you can log-off and watch your favorite movie. To check the progress of the calculation, just log-in again and enter “screen -r”. To log-off, detach, i.e. Ctrl-a and then d. If the calculation is done, you “exit” from “screen”.
