I'm working on a certain SNS bot, but when I close the mac screen, it stops running, so
I tried to run it with the command nohup, but is it still asleep? It stops when I close the screen.
How can I continue to execute the command?
By the way, python executable
I'm sorry I'm weak...
python macos
If you answer what the title says faithfully, it is impossible to execute the command in a sleep state.In the sleep state, the main memory state is maintained, but the CPU and hard disk are not running, so the program cannot run.I'm literally asleep.
You can only run programs when you are awake, so if you want to run a program in the background, you should not go to sleep, or you should go to sleep in some way.
Incidentally, the Mac has a feature called PowerNap that allows you to temporarily boot up and run programs in the background even when you're asleep, but unfortunately you can't run any programs because this is only for OS services.
It's not Python, but RubyOnRails created a batch of web apps to scrap a site, created a system to tap the start URL with cron every few minutes, and tested it with my macbook pro, but when I closed my PC for a day and opened it the next day, it was still closed.
The processing itself is threaded, and the web server itself is back-end-launched in the shell.
Perhaps if Python is simply started as a front process in a terminal, it will fall asleep if it is closed, but if it is started like a daemon as a backend, will it continue to run?
I don't know what kind of implementation is in Python, but if you're using FW such as Django, you'll probably have a backend boot option.
Note:
I'm sorry, but if I close the MAC, it will be completely asleep, so even if I turn it into a daemon, the processing will stop.
We have verified that the process continues in energy-saving mode (if the screen saver is displayed after being left for a certain period of time).
So if you leave the screen open, at least the daemon process will work.
By the way, I wrote down the process of writing the current time to a file every 3 seconds on Python and tried it from the terminal, but when I open the screen, the process resumes without permission. Can't this be solved?
© 2024 OneMinuteCode. All rights reserved.