15
$\begingroup$

I have a notebook(.nb) which its calculation is time-consuming and long. I can not observe it if the calculation is done or not. Therefore, I want to :

  1. Save the results in the notebook(.nb) ( I do not want to save the data in a .Xls,.CSV,... file) and then
  2. Use a command in that notebook(.n) to shut down the computer from Mathematica when the calculation and saving the data is done.

I wonder if you could possibly help me with this problem.

P.S: I have already searched the documentation and found NotebookSave[] command, but I'm not sure if it is a proper command to save the notebook. However, I couldn't find anything relate to shuting down the computer after calculation.

$\endgroup$
8
  • $\begingroup$ I think a similar question has been asked before, but I neither remember it clearly nor the solution if any was given. $\endgroup$
    – Mr.Wizard
    Aug 6, 2014 at 17:50
  • $\begingroup$ I suspect best way to shut down will be to use a command line script. What OS are you running? $\endgroup$
    – Mr.Wizard
    Aug 6, 2014 at 17:53
  • $\begingroup$ @Mr.Wizard: The OS is " Windows 8 ". So you mean there is no way ?! $\endgroup$
    – Shellp
    Aug 6, 2014 at 17:57
  • 2
    $\begingroup$ @Mr.Wizard - I think you may have remembered: this $\endgroup$
    – Jagra
    Aug 6, 2014 at 18:20
  • 2
    $\begingroup$ How about this? Run[...] should work. $\endgroup$
    – Öskå
    Aug 7, 2014 at 9:53

1 Answer 1

10
$\begingroup$

On Windows this works for me:

Pause[1];
1 + 1       (*you can add Save or Export here ofc*)
NotebookSave @ EvaluationNotebook[];
Run["shutdown -t 2 -s"];

NotebookClose[]

For command explanation take a look at the link Öskå has provided:

SO:162305

$\endgroup$

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.