# macOS Launchd SOP

## Service Creation
Create `~/Library/LaunchAgents/com.agent.task.plist`:
```xml
<!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.agent.task</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/python3</string>
        <string>/path/to/script.py</string>
    </array>
    <key>StartInterval</key>
    <integer>3600</integer> <!-- Every hour -->
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
```

## Commands
- Load: `launchctl load ~/Library/LaunchAgents/com.agent.task.plist`
- Unload: `launchctl unload ~/Library/LaunchAgents/com.agent.task.plist`
- Logs: `log show --predicate 'process == "com.agent.task"' --last 1h`
