Welcome to Justanswer.com, my name is ***** ***** I will do my best to assist you.
Lets try a simple repair and then see if the mac stays on.. if so, this will help isolate what the cause might be, and then we can work to repair it.
Shut down your Mac.Locate the following keys on the keyboard: Command (⌘), Option, P, and R.Turn on your Mac.Press and hold the Command-Option-P-R keys immediately after you hear the startup sound.Hold these keys until the computer restarts and you hear the startup sound for a second time.Release the keys.
Then, Hold down the SHIFT key while your mac is starting.. You must press and hold the shift key as soon as you press power to start the mac.
This should start it in safe mode.. Will it stay on in safe mode longer then an hour?