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've had Mathematica crash on me a number of times, and have had to recreate notebook contents from the last save point.

I was looking for something in the preferences like an autosave frequency configuration parameter that I could use to automatically save all my notebook content at some regular frequency to minimize losses due to crashes.

I found NotebookSave[], and a NotebookAutoSave -> True attribute for CreateDocument, but both these appear to be for manipulating external notebooks. Is there a way to do this systematically and by default?

share|improve this question
I don't think there's such an option. In any case, this answer might be relevant for your needs. What it does is it saves a copy of the current notebook (with a .backup extension) upon every cell evaluation. –  rm -rf Nov 2 '12 at 5:08

3 Answers 3

up vote 6 down vote accepted

You can set the NotebookAutoSave preference programmatically or via the Option Inspector.

To turn autosave on by default for all notebooks, you could do:

CurrentValue[$FrontEnd, "NotebookAutoSave"] = True

You can also set the option for individual notebooks by changing $FrontEnd to the appropriate notebook handle. According to the docs, NotebookAutoSave saves after every evaluation and seems to be inflexible in that regard.

share|improve this answer
Excellent. With that and checking in my notebooks to my git repository, I should have decent recoverability. I can always rollback to my last VCS commit (provided I explicitly commit after interesting changes) should I not like what has gotten autosaved, but should avoid losses due to unforeseen crashes. –  Peeter Joot Nov 3 '12 at 1:18

You could try executing

    EmitSound[Sound[SoundNote[]]];NotebookSave[EvaluationNotebook[]], 10];

which saves the notebook every 10 seconds and plays a note.

share|improve this answer

I have a Mathematica package that provides auto-backup functionality. When enabled, the current notebook--call it "blah.nb"--will be backed up to "blah.nb~" after a configurable amount of time has elapsed. I use it constantly and it has saved me from losing work many, many times. It's better than autosaving since it doesn't touch the actual notebook file: if you screw something up or something gets corrupted you don't want to overwrite your main file. :)

It's on GitHub here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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