Skip to content

Instantly share code, notes, and snippets.

@petarov
Last active September 25, 2024 10:11
Show Gist options
  • Save petarov/870fa6c392aff25e84aa0913b91748c6 to your computer and use it in GitHub Desktop.
Save petarov/870fa6c392aff25e84aa0913b91748c6 to your computer and use it in GitHub Desktop.
macOS launchd scheduled run
<?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>net.vexelon.petarov.name</string>
<key>ProgramArguments</key>
<array>
<string>/<path>/<executable></string>
<string>/<path>/<param></string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Weekday</key>
<integer>5</integer>
<key>Hour</key>
<integer>9</integer>
<key>Minute</key>
<integer>40</integer>
</dict>
<key>StandardOutPath</key>
<string>/<path>/output.log</string>
<key>StandardErrorPath</key>
<string>/<path>/error.log</string>
</dict>
</plist>
@petarov
Copy link
Author

petarov commented Sep 25, 2024

To check its syntax:

plutil -lint <name>.plist 

To schedule copy or symlink it to your agents folder:

cp  <name>.plist  ~/Library/LaunchAgents/<name>.plist  

To reload:

launchctl unload ~/Library/LaunchAgents/<name>.plist  
launchctl load ~/Library/LaunchAgents/<name>.plist  

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