Schedule to run automatically on a Mac - ngovil21/Plex-Cleaner GitHub Wiki

On Mac OSX, the best way to schedule a script to run everyday is through Launch Agent.

To create a Launch Agent you first have to create a plist file for the Daemon. In text edit copy and paste the following text:

<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
<plist version="1.0">  
    <dict>  
       <key>Label</key>  
       <string>com.ngovil21.plexcleaner</string>  
       <key>ProgramArguments</key>  
       <array>  
       <string>/usr/bin/python</string>  
       <string>/path/to/your/plexcleaner/PlexCleaner.py</string>  
    </array>  
    <key>StartInterval</key>  
        <integer>300</integer>  
    </dict>  
</plist>  

Set /usr/bin/python to the actual path of your python application if different and change /path/to/your/plexcleaner/PlexCleaner.py to the actual full location of the PlexCleaner.py file on your computer.

You can also change 300 to some other number that will be the number of seconds in between runs. 300 is 5 minutes. 86400 would run the script once a day.

Save this file as com.ngovil21.plexcleaner.plist on your Desktop, then in Terminal run:

cp ~/Desktop/com.ngovil21.plexcleaner.plist ~/Library/LaunchAgents/com.ngovil21.plexcleaner.plist

If you are on Yosemite, you must also run the next two commands which require administrator privileges. If you're running a version before you can skip this step:

sudo chmod 0600 ~/Library/LaunchAgents/com.ngovil21.plexcleaner.plist
sudo chown root ~/Library/LaunchAgents/com.ngovil21.plexcleaner.plist

Finally run this command:

launchctl load ~/Library/LaunchAgents/com.ngovil21.plexcleaner.plist

That's all there is.

This guide was adapted from the installation instructions for PlexPy and was created by randybruder.

⚠️ **GitHub.com Fallback** ⚠️