5

I have a well-honed Control-S reflex (i.e. I obsessively save my work), but when Mathematica crashes with a file open the saved changes are not recovered when I restart Mathematica and open the file. It reverts back to the file's state when I first opened it before making (and saving) any changes.

How can I actually save my work, without needing to save, close and re-open a notebook with the same obsessive regularity that I "save"?

I'm running Mathematica 8.0 on a Windows XP x64 machine.

Edit: Just to clarify, I'm not so worried about the crashing. I'm concerned about saving not actually saving.

Eli Lansey
  • 1,100
  • 2
  • 14
  • 28
  • If you quit Mathematica normally, are your changes successfully saved? – Brett Champion Dec 13 '11 at 15:28
  • Yes, if I close the file (and/or Mathematica) normally then the changes are saved – Eli Lansey Dec 13 '11 at 15:31
  • Can you evaluate `Options[EvaluationNotebook[]]` from within the notebook and post the result? Or post the notebook somewhere? – Brett Champion Dec 13 '11 at 15:39
  • @BrettChampion {FrontEndVersion -> "8.0 for Microsoft Windows (64-bit) (November 7, 2010)", StyleDefinitions -> "Default.nb", WindowMargins -> {{Automatic, 42}, {39, Automatic}}, WindowSize -> {1370, 794}} – Eli Lansey Dec 13 '11 at 15:43
  • Well those options are nice and boring. :-) Is the notebook especially large, or live in some 'special' location on your hard drive? – Brett Champion Dec 13 '11 at 15:47
  • So, you save the file and what causes the crash? –  Dec 13 '11 at 15:49
  • And you do not have the notebook open in another M- session? –  Dec 13 '11 at 15:50
  • Not particularly. It's not filled with crazy things, either. It's a fairly boring notebook. I'm less concerned about the crashing than I am about the lack of saving. – Eli Lansey Dec 13 '11 at 15:50
  • @ruebenko The crash can be caused by any number of different reasons (opening a different, corrupt notebook; graphics overload; dog ate my RAM; etc). I'm not so worried about that. My concern is that my file is not actually saved when I think it is. – Eli Lansey Dec 13 '11 at 15:53
  • @Eli I am trying to figure out if the crash prevents M- from saving the file properly. But it seems there is a fair amount of time between the save and the crash. –  Dec 13 '11 at 15:58
  • @ruebenko Plenty of time. I can be working on a file all day, saving all the time. Then the front end crashes and I lose the work saved many times over the course of many hours. – Eli Lansey Dec 13 '11 at 16:00
  • May be you can try to restore M to its original factory shipped state and see if this problem remain? Sometimes this for me solved some strange problem (but not as strange as yours). Before starting M, hold the SHIFT and CONTROL key down, keep holding them down while starting M until the M flash screen comes up. Now release the keys. This will reset M init files. something to try... – Nasser Dec 13 '11 at 23:45
  • This just happened to me with Mathmematica 12 on Windows 10. Two days of work lost, despite frequent saving! Infuriating. – David Feb 15 '21 at 07:50

3 Answers3

2

This may be a case of Windows not flushing its disk cache to disk. You might want to try the Sysinternals' tool Sync. "Use it whenever you want to know that modified file data is safely stored on your hard drives."

You can have Mathematica call Sync using Run and automate the process in the background using scheduled tasks like in this answer.

Community
  • 1
  • 1
Sjoerd C. de Vries
  • 16,002
  • 3
  • 41
  • 90
1

I have a similar problem with Mathematica 10, my temporary solution is to save to a filename with a name ending with "a" - "filenamea.nb", and switch and save to a name ending with b "filenameb.nb".

I've been using Dropbox to restore older version until I discovered that in this version Mathematica doesn't flush the files (at all it seems unless you close the file). This is especially a problem when it crashes.

It is possible that some of this could be tweaked in the advanced options, but I couldn't figure out how yet, I posted a question with Wolfram. To be continued...

qpd
  • 11
  • 1
  • Your message is from 7 years ago, but did you get an answer from Wolfram? I just had the same issue with Wolfram 12 on Windows 10. – David Feb 15 '21 at 07:51
1

Edit->Preferences->Advanced; Open Option Inspector.

Lookup: NotebookAutosave

This will save every time you press shift+enter. It can be a disk burden for large files.

  • Again, I do _save_ the files, it's just that with a crash the saves don't stick. Were I to close and re-open the file, the saves stick. – Eli Lansey Dec 13 '11 at 15:36
  • So the star in the file name did vanish? Sometimes you press Ctrl+S and think the notebook was saved but it was not. –  Dec 13 '11 at 15:40
  • The best solution to this problem is not to type anything that will cause Mathematica to crash :) – Nasser Dec 13 '11 at 22:51
  • 3
    @NasserM.Abbasi: A strange game. The only winning move is not to play. Care to play a nice game of chess? – Mike Bailey Dec 14 '11 at 00:28