赞
踩
参考:https://stackoverflow.com/questions/52197941/xcode-build-works-from-command-line-but-not-in-crontab
crontab 默认使用 root 执行,无法访问用户login keychain
改用 launchd 设置定时任务即可解决:
$ launchctl load -w test.plist
$ launchctl start com.test.start.auto
$ launchctl list | grep com.test.start.auto
test.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">
- <dict>
- <key>Label</key>
- <string>com.test.start.auto</string>
-
- <key>ProgramArguments</key>
- <array>
- <string>/Users/test/test.sh</string>
- </array>
-
- <key>StartCalendarInterval</key>
- <dict>
- <key>Hour</key>
- <integer>16</integer>
- <key>Minute</key>
- <integer>37</integer>
- </dict>
-
- <key>RunAtLoad</key>
- <true/>
-
- <key>StandardErrorPath</key>
- <string>/Users/test/test.err</string>
-
- <key>StandardOutPath</key>
- <string>/Users/test/test.out</string>
- </dict>
- </plist>

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。