Script save itself

This may be silly, but I recently lost some progress because my script made ansys crash. Its no big deal, but I was wondering if there was a way to make my script save itself in a line of code, acting as a form of autosave. Does this exist? Thank you