I'm sure a lot of people have encountered the situation where they run some stuff, realizing it not only stuck the program, but they also haven't saved for the last 10 minutes!
EDIT
After suffering from this for some time, I one day found out that one can create auto-save from within the Mathematica code. I think that using such auto-save have helped me a lot in the past, and I always felt that the possibility itself was something that not a lot of people are aware that they can do.
The original code I used is at the bottom. Thanks to the comments I've found out that it is problematic, and that it is much better to do it in an alternative way, using ScheduledTask
(which will work only in Mathematica 8).
Code for this can be found in this answer from Sjoerd C. de Vries
(Since I'm not sure if it's OK to copy it to here, I'm leaving it as a link only.)
The solution below is using Dynamic
. It will save the notebook every 60 seconds, but apparently only if its cell is visible. I'm leaving it here only for completion reasons. (and for users of Mathematica 6 and 7)
/EDIT
To solve it I use this code in the beginning of a notebook:
Dynamic[Refresh[NotebookSave[]; DateString[], UpdateInterval -> 60]]
This will save your work every 60 seconds.
I prefer it to NotebookAutoSave[]
because it saves before the input is processed, and because some files are more text than input.
I originally found it here: http://en.wikipedia.org/wiki/Talk:Mathematica#Criticisms
Note that once running this line, saving will happen even if you close and re-open your file (as long as dynamic updating is enabled).
Also, since there is no undo in Mathematica, be careful not to delete all your content, since saving will make it irreversible (as a precaution move, I remove this code from every finished notebook)