【FAQ】通過 crontab 定時執行 xcodebuild 打包簽名,無法解鎖鑰匙串?

參考: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>

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章