My iphone always restarts by itself
The best thing to do is to first try a backup and restore as new as detailed in 


  http://support.apple.com/kb/HT4137 


A lot of the time a device restarting multiple times can be caused by a software issue, and frankly getting all your data on the computer is always a  a good idea. 

This will also make sure you are updated to the most recent version in case you are working with old software.
If it doesn't work it is probably time to get a new one or go for a repair.