Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 511
Liam Williamson Avatar asked May 09 '26 20:05

Liam Williamson


1 Answers

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

like image 112
JacoSolari Avatar answered May 11 '26 10:05

JacoSolari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!