Run Python Script at OS X Startup

后端 未结 3 892
陌清茗
陌清茗 2020-12-13 07:35

I am very new to python as well as MAC OSX. For my academic project I need to download a bunch of tweets from twitter using twitter streaming API. I need to download atleast

3条回答
  •  有刺的猬
    2020-12-13 08:10

    Adapt the following accordingly, name it something like myscript_launcher.plist, and put it in either one of three locations: /System/Library/LaunchAgents, /System/Library/LaunchDaemons, /Users//Library/LaunchAgents.

    
    
    
    
        Label
        my.python.script.name
        ProgramArguments
        
            /path/to/python
            /path/to/python/script.py
        
        StandardErrorPath
        /var/log/python_script.error
        KeepAlive
        
    
    
    

    Also, let's assume you put the plist file in ~/Library/LaunchAgents. You can start and stop it with the launchctl. To start, use launchctl load ~/Library/LaunchAgents/myscript_launcher.plist. To stop it, do the same but use the unload argument

提交回复
热议问题