9

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!

8
  • 1
    If on Win, wrap it in a cmd (batch) script and set it up as a service. If on Linux, add it to systemd. Here is a nice and simple systemd tutorial. Commented Apr 17, 2020 at 12:19
  • You can use Py2Exe to turn the script into an executable. Commented Apr 17, 2020 at 12:20
  • 1
    @S3DEV Hmm, a batch script makes so much more sense. Commented Apr 17, 2020 at 12:21
  • What do you mean "even when my computer is sleeping"? Like when computer is in Sleep Mode? Commented Apr 17, 2020 at 12:23
  • Is it a windows or a Mac/Linux machine? Commented Apr 17, 2020 at 12:25

1 Answer 1

24

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

Sign up to request clarification or add additional context in comments.

1 Comment

This is the only time that apple has had a one line answer to one of my questions regarding the terminal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.