Running Python in background on OS X
问题 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" python script on a USB drive? 回答1: If you want to have the script running as a daemon process which starts automatically, you can use launchctl and a plist file. For example, Bob has a simple python script which writes the word 'foo' to a file every second in his home directory: #!/usr/bin/env python import os import time