launchd sop

下载 .md

macOS Launchd SOP

Service Creation

Create ~/Library/LaunchAgents/com.agent.task.plist:

<!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

评论(0)

登录 后可发表评论。

暂无评论。