Running Python in background on OS X

后端 未结 5 1888
广开言路
广开言路 2020-12-04 11:27

Is there any way to keep my Python script (with an endless \'while\' loop) running in the background on OS X? Also, for the same purpose, is there any way to have \"autorun\

5条回答
  •  一向
    一向 (楼主)
    2020-12-04 12:05

    Just run your Python script in the background using the shell in the usual way:

    python myscript.py &
    

    As for the autorun question, this would be a huge security hole if it was something that Mac OS X did by default, so, no, of course not. But you could easily write a script that implemented something like that on purpose: periodically look for a USB drive plugged in, and do something (even run a second script from the thumb drive) when it's plugged in.

提交回复
热议问题