Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am working in a Linux machine.The name of my mathematica file is deres.nb

Code:

a={};
AppendTo[a,1];
a>>"file"

Now, if I run this code, by simply evaluating the cell, there is no problem, I get the file saved in the directory I am working.

But I want to run a script. Then I prepare my file by:

1.Cell -> Cell Properties-> Initialization Cell

2.I save the file with a .m extension(deres.m)

3.Format -> Style -> Code

Now I run the script by writing in the terminal:

  1. screen

  2. math -script deres.m &

Then I exit by writing "exit".

The problem is that I do not get my file saved.

This works perfectly for me in Mathematica 8.

Any solution please?

Thanks a bunch.

share|improve this question

closed as off-topic by m_goldberg, bobthechemist, Sjoerd C. de Vries, Michael E2, Kuba Feb 5 at 9:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, bobthechemist, Sjoerd C. de Vries, Michael E2, Kuba
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
This is not an issue with Mathematica. When you type exit, you're terminating the complete session, including mathematica and screen. You can try running nohup math -script deres.m & instead. –  Szabolcs Feb 4 at 16:56
    
@Szabolcs, indeed, I terminate and there is no problem(in Mathematica 8) with that, as long as the job is finished before I "exit". This job it takes like 10^-5 sec to be finished. –  Mencia Feb 4 at 16:59
    
@Szabolcs, thankyou thankyou thankyou!!!It works... –  Mencia Feb 4 at 17:07

1 Answer 1

up vote 2 down vote accepted

This is not an issue with Mathematica itself. It's related to how you closed the session on the remote machine.

If you use screen, you should detach from the current screen session before exiting, otherwise you'll close the current shell together with its child processes, including Mathematica.

Alternatively, just use nohup, and do not bother with screen:

nohup math -script deres.m &
exit

Mathematica will keep running in the background even after you terminate your shell session.

share|improve this answer

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