I would suspect bad capacitors on this machine. To get you to the correct guide to open it, please give us the last three figures of your serial number located on the bottom of your stand.
UPDATE Now that I know your machine model, I do not suspect capacitors. Did you replace the hard drive?
Try starting up in Safe Mode by holding down the Shift key on start up and let us know if the issue persists.
crwdns2934105:0crwdne2934105:0
crwdns2934113:0crwdne2934113:0
crwdns2915270:0crwdne2915270:0
crwdns2889612:0crwdne2889612:0
2
crwdns2942205:01crwdne2942205:0
Your systems specs: iMac 21.5" 2.7 GHz i5 (Late 2012)
crwdns2934271:0crwdnd2934271:0 Dan crwdne2934271:0