Skip to content

Instantly share code, notes, and snippets.

@unkwn1-repo
Created June 18, 2019 06:28
Show Gist options
  • Save unkwn1-repo/11c77a0a86c2f0952d68198194daae7b to your computer and use it in GitHub Desktop.
Save unkwn1-repo/11c77a0a86c2f0952d68198194daae7b to your computer and use it in GitHub Desktop.
An example launchd plist file. The launchd agent will first change the working directory, set the arguements and, execute a python script. This is a minimalist launchd template that can easily be expanded upon.
<?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.nuntium.fetchnews.agent</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/python3</string>
<string>nuntium.py</string>
<string>--fetch-news</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>600</integer>
<key>WorkingDirectory</key>
<string>/Users/jessefogarty/Google Drive/github/nuntium/nuntium</string>
</dict>
</plist>
@unkwn1-repo
Copy link
Author

I wrote this in order to automate my Nuntium project. Oh how I relish crontab so much more after this.

end result is akin to running:

$ cd /Users/jessefogarty/Google Drive/github/nuntium/nuntium
$ python3 nuntium.py --fetch-news

every 10 minutes.

Where to install your plist file

~/Library/LaunchAgents/

Loading your plist file

$ cd ~/Library/LaunchAgents/
$ launchctl load <plist>

Default logs

When checking the system.log output you know you plist was loaded fine IF there's no error to check run:

$ cd /var/log
$ grep '<plist file name>' system.log

Feel free to include a snippet of your plist code if you're having trouble and I'll do my best to help you fix it.

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment