How to fix my ps3 cuz it keeps shutting off by itself?

Sometimes it shuts off right after I turn it on, sometimes it works for about 10 mins and when I watch a movie or play minecraft it doesn't shut off. When I play something like final Fantasy it shuts off after about a minute. When it turns off the light goes green, yellow then flashing red
How do I fix it thanks in advance

You can't, your ps3 is dying and will probably be totally dead within days or weeks so if you don't want to lose all your game progress you'd better get playstation+ and upload your saves to the cloud before your ps3 has permanent ylod and is only good for use as a doorstop or anchor

It's probably overheating. You can open the system and clean it out, but it's probably going to need to be sent to a repair center.