python – How to keep executing commands even in sleep mode on mac

Question: Question:

I'm working on a bot for a certain SNS, but when I close the mac screen, it stops running, so
I tried to execute it with the command nohup, but is it in sleep mode even with it? It stops when I close the screen.
How can I keep the command running?
By the way, it is an executable file of python.

Sorry for the weakness …

Answer: Answer:

If you faithfully answer what is written in the title, it is impossible to execute the command in sleep mode. In the sleep state, the state of the main memory is maintained, but the CPU and hard disk are not running, so the program cannot be executed. I'm literally sleeping.

You can only run the program when you are awake, so if you want to run the program in the background, you need to either not put it to sleep or wake it somehow.

By the way, Mac has a function called PowerNap, which has a function to temporarily wake up even in sleep state and execute a program in the background, but unfortunately it is like executing an arbitrary program because it is dedicated to the OS service. You can not.

Scroll to Top