Prevent Mac sleep during a long terminal command

Đội ngũ LidRun
5 phút đọcJun 2026

Scripts, syncs, and data jobs in the terminal can run longer than the idle sleep timer allows. Here is how to prevent Mac sleep during a long terminal command and let battery and thermal limits decide when it should end.

Why long commands get cut off

A command in Terminal runs as a normal process. If you step away and the Mac hits its idle timer, or you close the lid, the Mac sleeps and the command is suspended.

Long-running scripts, large file syncs, and data jobs are the ones most likely to outlast the idle timer, which is exactly when a sleep interruption costs you.

The LidRun workflow for terminal jobs

LidRun can detect common terminal jobs and hold the Mac awake while they run, so a long command finishes without interruption.

Battery and thermal thresholds gate the session. If charge drops or heat climbs past your limits, LidRun lets the Mac sleep rather than overworking it.

For a one-off command, the lidrun CLI can hold a short-lived keep-awake assertion just for that run and release it when the command exits.

A practical setup

Plug in for long jobs, start your command, turn on keep-running mode, then close the lid if you want to step away.

Set a session timer so the run has a clear upper bound even if a script hangs.

To set this up on your Mac, see the plans on /pricing or download the app from /download.

Thử nó thay vì vật lộn với ngủ khi gập máy

LidRun giữ công việc của bạn chạy tiếp khi đóng nắp, với cơ chế bảo vệ pin và nhiệt tích hợp sẵn.

Tải cho macOS

Câu hỏi thường gặp

Can I keep the Mac awake for just one command?

Yes. The lidrun CLI can hold a keep-awake assertion for the duration of a single command and release it when the command finishes.

Will it keep running with the lid closed?

Yes, with keep-running mode on, as long as battery and thermal state stay within the thresholds you set.

What if my script hangs?

A session timer caps the run at one, three, or eight hours, so a hung command does not keep the Mac awake indefinitely.

Đọc tiếp

Prevent Mac Sleep During a Long Terminal Command