Skip to content

Instantly share code, notes, and snippets.

@pwrliang
Last active June 3, 2019 06:31
Show Gist options
  • Save pwrliang/092b1ff42a11ffb36a8fc29e3e03ddbe to your computer and use it in GitHub Desktop.
Save pwrliang/092b1ff42a11ffb36a8fc29e3e03ddbe to your computer and use it in GitHub Desktop.
Mac OS startup
<!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.v2ray</string><!--这个名字必须和文件名一致, 不含.plist-->
<key>Program</key>
<string>/opt/v2ray/v2ray</string>
<key>ProgramArguments</key>
<array>
<string>-config</string>
<string>/opt/v2ray/config.json</string>
</array>
<key>KeepAlive</key><!--后台保持运行-->
<true/>
<key>RunAtLoad</key><!--加载时候运行-->
<true/>
</dict>
</plist>
文件位置:/Library/LaunchDaemons/com.shadowsocks.plist
-rw------- 1 root wheel 645 Jan 30 18:32 com.shadowsocks.plist
命令:
launchctl list
launchctl load ~/Library/LaunchAgents/local.restart.plist
launchctl unload ~/Library/LaunchAgents/local.restart.plist
launchctl start local.restart
参考:
https://www.maketecheasier.com/use-launchd-run-scripts-on-schedule-macos/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment