4
$\begingroup$

I need to run a long evaluation on my research group machines at university (Scientific Linux 6 , Mathematica 9). I just connect via ssh and work on math text-based environment. I can't find a way to let MathKernel processes go on when I log-out the ssh connection. I tried to put them in background using & and nohup, and I also tried to "daemonize" them, but no one of these attempts worked. Processes start properly, and they generate the output files they are supposed to. I can monitor them using "top" command on a secondary shell, and I can see them die when I close the primary shell or I exit the ssh connection on it. I read about some issues Mathematica has with csh/tsch shells, but i did not find a valid solution to my problem. Can someone suggest a possible solution?

Thanks

$\endgroup$
6
  • 5
    $\begingroup$ GNU screen or NX $\endgroup$ Commented Dec 14, 2015 at 18:07
  • $\begingroup$ Thanks, @mmal . I forgot to specify I cannot install anything on the severs because I am not system administrator. By the way, I knew about Screen, but I didn't know about NX tech, so thanks for improving my knowledge. $\endgroup$ Commented Dec 14, 2015 at 22:31
  • $\begingroup$ @DomenicoGuida, when you say you use & and nohup, are you still using an interactive session, meaning do you see "In[1]:= "? $\endgroup$ Commented Dec 15, 2015 at 8:37
  • 2
    $\begingroup$ Unless execute permission is denied on home directories, then you can still build and use programs like screen without being a system administrator. It is not necessary for these programs to be in /usr/bin to run. Just build it with --prefix=<somewhere in your home directory>. Or, if your system administrator(s) are helpful, just ask them to install GNU screen for you. It is a very commonly used program. $\endgroup$ Commented Dec 15, 2015 at 12:05
  • $\begingroup$ @JasonB, I only see "Launching Kernels..." and nothing else. If I launch a short process and wait, the prompt comes back when process finishes. If I close the terminal window all related processes stop. $\endgroup$ Commented Dec 15, 2015 at 12:09

1 Answer 1

3
$\begingroup$

If this is how you are already doing things, let me know. But for me, running on a remote kernel means running in batch mode; no method of accessing a GUI, or using an interactive prompt is as reliable.

So, on the remote machine, create a text file called "test.m" in the directory where math usually starts, and put the following contents inside it

Do[ Pause[5.]; Print["paused for " <> IntegerString[5 n] <> " seconds"]; , {n, 12}]; Export["test.dat", {#, #^2} & /@ Range[500]]; Exit[] 

This will run for two minutes, then output a simple matrix to a file.

Now you log in to the remote server via ssh and run that command via

nohup nice math -noprompt -run "<<test.m" > output & 

What that is doing is opening math without a prompt, and running the single line <<test.m

The output from the Print command should go to the file output, and the matrix should go the file "test.dat". It should run for 2 minutes so that is plenty of time to log out, wait, then log back in to see if the files were created.

I learned this from @Jens, detailed on this page. At the time, I was running calculations on the University of Oregon's cluster (where Jens is a professor), and we had a really awesome site license so I could submit hundred of Mathematica jobs - which is why I didn't learn any other programming language until leaving grad school.

$\endgroup$
1
  • 1
    $\begingroup$ I think it may be better to not to use Exit[] in the scipt (since it can also be used in interactive session, or nested in other script) and use math -noprompt -run "<<test.m; Exit[]; > output & instead. $\endgroup$ Commented Dec 16, 2015 at 8:16

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.