macos launchd plist
~/Library/LaunchAgents/com.example.myapp.plist:
<?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">
<!-- https://superuser.com/a/229792 -->
<!-- https://opensource.apple.com/source/launchd/launchd-257/launchd/doc/HOWTO.html -->
<!-- https://launched.zerowidth.com/ -->
<dict>
<key>Label</key>
<string>com.example.myapp</string>
<key>UserName</key>
<string>handsome</string>
<key>WorkingDirectory</key>
<string>/Users/handsome/dev/myapp/</string>
<key>ProgramArguments</key>
<array>
<string>./myexe</string>
<string>arg1</string>
<string>arg2</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>Crashed</key>
<true/>
</dict>
</dict>
</plist>
加入启动项
launchctl load ~/Library/LaunchAgents/com.example.myapp.plist
启动
launchctl start com.example.myapp
移除启动项
launchctl remove com.example.myapp
查看帮助
launchctl
+V why_null 请备注:from博客园