0
$\begingroup$

I have converted my Mathematica notebook into .m file and need to run it in the background on a remote server. I am launching the run from my laptop, on a remote workstation. I need it to obey the follwoing conditions:

  1. It should not get aborted when I close my laptop terminal/my internet connection gets severed; it should continue to run on the workstation

  2. It should give me output and error messages in the .log/.out file and also an indication in the end showing that the run is complete.

I have tried 2 codes:

nohup time math < file.m > file.out &

nohup math -run "<<file.m" &> file.out&

The first command aborts when I close my laptop terminal, and the second command doesn't follow the second condition. I need both the conditions satisfied. Is there another command which I can use?

$\endgroup$
3
$\begingroup$

This is bash session i assume, and not directly related to mma, however the easiest way to do this is run screen

Run on your server:

screen
Command (whatever your command is)
ctrl+a d

And this will detach the screen and the command will run in background allowing you to disconnect and the screen session will run on the workstation in the background and close when its done.

$\endgroup$
2
  • $\begingroup$ This won't help because I will have to keep my laptop up and running all the while when I'm running the command on the workstation. I do heavy data analysis which can run for a couple of days or more at a stretch. I want it to keep running on the workstation regardless of whether my laptop is on/off. $\endgroup$ – Divyajyoti Apr 5 '20 at 14:18
  • 4
    $\begingroup$ Then listen to what i said and use screen? $\endgroup$ – morbo Apr 5 '20 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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