Alright.
Reset the BIOS if not done so already. There's also a possibility that the system is overheating, though if you're computer turns off just a few seconds of being turned on after having rested for a while, then it's highly unlikely. But make sure that vents, heatsinks and fans are free of dust anyway.
My next step would be to remove/disconnect any unnecessary hardware from your computer (including hard drives and PCI sound card if you have one) leaving just the essentials connected (motherboard, RAM, processor, graphics card, keyboard, mouse and monitor...keeping heatsinks and fans installed, of course).
If you've got multiple RAM modules installed, install just one RAM module. Turn the PC on and see if the problem persists. Also try swapping RAM modules with other modules (if you've got more than one) and power on to see if you get the same problem.
If the problem still exists at this stage then it's likely that your PSU, RAM, CPU or motherboard is faulty. You may need to troubleshoot by swapping these components one by one with other components. Start with the PSU.