When is it shutting down during the startup process:
1.) Before or after startup chime?
2.) Before or after Apple logo?
3.) Before or after Apple logo with spinning gear?
4.) Before or after blue screen that appears after the Apple logo with spinning gear?
5.) On username authentication? (if auto-sign on is disabled)
6.) On Desktop load? (if auto-sign on is enabled)
Check out this article -
The article is written so that you'll want to follow it from top to bottom.
1.) Try a Safe Boot
2.) Try Disk Utility
3.) Use fsck if necessary
Given when the machine is shutting down it seems unlikely to be an OS issue as it never gets to the blue screen. A reinstall of the OS if all of the steps in the article fail wouldn't hurt but it's unlikely to fix the issue if all those other recommendations fail.
In the event that all those repair options fail then the next stop is a trip to the Genius Bar as the drive itself may need to be replaced.