2

New here so apologies if this has been asked and answered before.

I have these Mathematica programs that run for a couple of weeks.

We have a Linux server that has Mathematica on it. I tried connecting to this server via Putty etc. but the connection keeps dropping.

I have a vague memory from years ago (it may have been a Unix based system) of a one line command that would load a Mathematica notebook, read in the contents and run it, and then output the results to a specified Mathematica notebook.

Can anyone tell me if something similar is possible with Linux?

Thanks,

Jimmy

  • I would suggest to use so called vnc servers, when computing on remote Mathematica. In particular, I use TigerVNC (https://tigervnc.org/). Of course to make connection secure, I would suggest to make secure tunnel over ssh. (I could share my setting if your decide to try this way). – Acus Oct 31 '22 at 15:14
  • Thanks, I do use a vnc connection and some showed me how to connect remotely to the server. The problem is (probably down to the way my University has configured the network) that the connection keeps dropping. What I would like to be able to do is log in and make the connection, set the program running, log out/break the connection (with the program continuing to run on the server) and then have the output accessible if I log on to the server at some later. I don't know how to do that, or even if it is possible. – James McLaughlin Nov 01 '22 at 17:30
  • Then you could try to run program using program named "screen". It allows to disconnect and reconnect to the program, which was started inside screen. Also vnc allows to reconnect after connection was interrupted. Seems that I cannot understand your problem – Acus Nov 02 '22 at 12:03
  • I will try to see if I can get screen working. The way I was using vnc, once the connection got broken, the Mathematica notebook stopped running. – James McLaughlin Nov 04 '22 at 01:53
  • Using vnc server/client approach you in fact run mathematica on remote machine, which presents screen to your local computer. Therefore you can disconnect and reconnect to the remote computer without affecting computations. It means that broken connection cannot affect computation. I think you are using different approach, not vnc . Or you put different meaning to what I call vnc. I myself use vnc for long computations. I often start job at work, then turn off work computer. When at home connect to remote vnc screen from different computer and everything works perfectly. – Acus Nov 04 '22 at 06:11
  • From the instructions I see, your are not using vnc. Your just open graphical console from your computer in the remote machine (in linux language your are making connection 'ssh -X remotehost'. Steps 1,2 create vpn tunnel. So, let's do the following experiment. After 1,2 and 3 steps (when on remote machine) try instead typing "mathematica" try to type "screen" . If that program is installed, then simple text terminal console window will appear. – Acus Nov 05 '22 at 16:43
  • Type "top" in that terminal. It should show all running processes in your machine. Then break connection (reboot local computer or close windows while command "top" is running). After that repeat all procedures, only instead of typing "screen" type "screen -r" . It should either open your screen with the "top" command running or will ask in addition a number of screen your want to reattach. In that case just repeat command "screen -r someNumber". Your should see process "top" running despite that connection was intentionally broken. If that will work, then I will say some words about vnc. – Acus Nov 05 '22 at 16:45
  • My colleague just told me the screen program has been installed, so I will try your suggestion when I get to the office on Monday. – James McLaughlin Nov 05 '22 at 22:52
  • I was able to get screen working. However, I think the problem with trying to run Mathematica is that it runs in its own external window, or notebook, and appears on my laptop screen exactly as if I had the Mathematica notebook open on my own laptop. When I exit/break the connection, the notebook does not continue running on the linux server/screen (nor on my laptop) and closes. There may be a way to do it (my colleague suggests converting the Mathematica program to a script and running the script without using the Mathematica GUI, so I will try that. Not ideal, but I will try it. – James McLaughlin Nov 06 '22 at 16:02
  • Figured something out from googling. Most here probably know this, but 1) convert all the notebook cells to initialization cells, 2) save the notebook as a .m file 3) run in a screen using the command MathematicaScript -script filename.m This will run in such a way that it is possible to disconnect from the screen and it will still be running when I reconnect to the screen. Thanks Acus for the help. – James McLaughlin Nov 06 '22 at 22:25
  • Even better is to send the output to a Mathematica notebook (which I am sure most here know).
    1. convert all the notebook cells to initialization cells,

    2. save the notebook as a .m file

    3. run in a screen using the command MathematicaScript -script filename.m > output.nb

    4. Open output.nb to check on progress or view output when done.

    – James McLaughlin Nov 07 '22 at 05:10
  • All that conversion is possible and your can use it with "screen" approach, since screen is devoted to run console programs (binaries MathKernel, math, wolframscript). If you want to run mathematica, then you have to use vnc server/vnc client approach. In particular your can test if some vnc server installed just typing Xvnc (capital matters). If it outputs something meaningful (for example Server is already active...) Then you have determite its type (mine prints TigerVNC 1.10.0 - built Apr 9 2020 06:49:31...). If not you can install locally in your home dir . – Acus Nov 07 '22 at 06:48
  • Then in your local computer you have to install vnc client and run it after vpn tunnel was created. These are general steps and for more concrete instructions your should consult linux of windows user groups. Also, your question is not related to Mathematica, since the program cannot control connection which is created by other means (putty in your case). In particular I use vnc server/client many years on a number of computers and am sure that it is best way to compute on remote Mathematica. As I mentioned we use tigervnc and tightvnc ( we run tigervnc server and tightvnc client ). – Acus Nov 07 '22 at 06:57
  • Here are relevant links: https://www.tightvnc.com/ and sample for setup (using realvnc server:yes the are plenty of vnc servers and clients) https://help.realvnc.com/hc/en-us/articles/360003474572-How-do-I-get-started-with-VNC-Connect-on-Linux- – Acus Nov 07 '22 at 07:00
  • Thanks for your help and the links. I had some confusion about the difference between vnc and vpn. – James McLaughlin Nov 08 '22 at 15:13

0 Answers0