Liam Williamson
Liam Williamson

Reputation: 99

How to make Python script running continuously while computer system in sleeping mode? (MacOS)

I'd like to keep my Python script running, even when my computer is sleeping.

I am using a Mac.

My file is only on my computer, not online.

I know of UptimeRobot, but I don't know how to configure that to my local file.

I would prefer to keep my file local, because it makes a lot of things easier for my project.

Is there anything that can help me achieve this? (not hardware, thanks.)

If you need more information, please leave a comment!

Upvotes: 8

Views: 14921

Answers (1)

JacoSolari
JacoSolari

Reputation: 1404

It's very simple.

  1. open a terminal

  2. type caffeinate

  3. press Enter

Once you have done this, your Mac will stay awake for as long as you leave the Terminal running.

You can minimize or hide it, and your Mac will not go to sleep until you use the keyboard shortcut Ctrl+C to interrupt the command.

source

Upvotes: 21

Related Questions