Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, August 13, 2026

How to Get an Extra Hour of Battery Life When a Long-Running, Can’t-Stop Workload Eats It in 15 Minutes

The situation

  • You are working on your laptop.

  • Your long-running (8-hour), terminal-launched, compute-intensive, iterative task, which produces data for the next iteration, is halfway through its work.

  • You need to take your laptop to a place where you will have no power source for a couple of hours.

  • At some point, your battery gets low and you receive a warning that the computer will soon go into sleep mode.

  • You should not put your computer to sleep because, apart from needing the computer for the activity you have there, sleep mode may interrupt connections and cause other undesired side effects that would disrupt the running task.

The solution?

1. Freeze the task/process

Get the process ID and run:

kill -STOP <your process id>

The task freezes, CPU usage drops, and your battery lasts much longer.


You can now keep working on other things, while your battery lasts much longer. I my case I it took more than an hour before getting back to my power adapter.

Once you return to a power source, connect your laptop.

2. Unfreeze the process

Run:

kill -CONT <your process id>

Your task resumes unaffected. Your work is safe.


Note: If your task was running in a terminal, you likely won't be able to run the unfreeze command from that terminal, because the terminal process itself is already frozen.

You will need to find an alternative way to run the command. For instance:

On Mac: use the Shortcuts app → New Shortcut → Shortcut type "Run shell" → set the unfreeze command → Run.

On Linux: there are also various methods, such as the "Run Command" or "Quick Run" prompt (Alt+F2), available in most Linux GUI variants.


Disclaimer: This is based on my personal experience. I have not tested multiple cases, such as having multiple parent-child processes used by or connected to the frozen task. Test it with your particular case and use with caution.

Good luck!

Dikran