I posted something very similar on Ask Ubuntu a long while ago, when I had a laptop that I just purchased produced similar symptoms to yours, from overheating¹.
When the symptoms occur, is the system powering down? (Is just the screen off, or does the whole system shut down?)
Of the machines I've had that were actively overheating, in my experience:
- Windows will just shut down. No blue screen, no warning, just "oh, my machine is off." It doesn't log the reason for this, but does do a "hmm, I appear to have not been shut down properly."
- Linux will do a graceful, but forced shutdown. The disks will unmount fine and everything, but applications will probably be forcefully closed. (Unsaved data will likely be lost.) If heat was the problem, Linux will, in my experience, log this. (This probably depends on exact setup & distro, though.)
Determining if heat is your problem
"Over heating" can be a difficult problem to isolate.
Find it in the logs. Check files in
dmesg logs, kernel logs, etc. In
/var/log/messages I had:
[ 9855.198401] thinkpad_acpi: temperatures (Celsius): 85 43 35 62 27 N/A 28 N/A 35 44 60 N/A N/A N/A N/A N/A
I later found another message that was even more explicit, along the lines of "hey, hit a temperature trip point, something is going critical". Unfortunately, I didn't record on Ask Ubuntu where I found this.
Watch the temperature of the machine. You can do this in a terminal by repeatedly running
sensors, which will show you something like:
temp2: +96.0°C (crit = +100.0°C)
Here, my second temperature sensor was at 96°C. (Note that the temp here is in Celsius: in this example, which was from a laptop I (briefly) owned, I'm a few degrees away from being able to boil water with this CPU. This is not a good thing.) The
crit = +100.0°C bit indicates a "trip-point", a point at which the OS will get concerned about the state of the hardware. (And shut down.) I was hitting at least one of these.
Being 4°C away from a trippoint is too hot. Being at 96°C is too hot. For comparison, my current desktop runs at 66°C when all the CPUs are at 100% — as I installed the heatsink/fan myself, a professionally built system should probably run cooler. When idle, it's about 33–36°C.
Note that while 96°C is hot enough to burn you, the laptop I had was touchable, and only "very warm". By the time you got to the case, the heat had dissipated enough.
Forcing the problem to reproduce
WARNING: what follows will cause a CPU to heat up, and if your CPU isn't being properly cooled, runs the risk of damaging the CPU. Use at your own risk. (I think some modern CPUs might have internal fail-safes against heat, but I'm pretty sure you're voiding your warranty here.) You can "provoke" an overheating quite simply: launch a number of infinite loops to heat up the CPUs.
python -c "while True: pass" will do this. (Ctrl+C to kill it.) (You might need to spawn multiple processes, one for each CPU. Take it gradually, and watch the heat output with
sensors) (Also, I've found that Minecraft is quite good at this as well.)
In my case, I used this to attempt to replicate the symptom, and further establish that it was indeed heat causing the problem.
¹Graciously, the purchase of my laptop came with a 30-day return-it-for-any-reason. The retailer's "techs" were "confident" that the machine wasn't overheating. (I'm confident they were wrong.)