MAC 編制計划任務


說明
1. /System/Library/LaunchDaemons是用戶未登陸前就啟動的服務(守護進程)。
  /System/Library/LaunchAgents是用戶登陸后啟動的服務(守護進程)。
2. /System/Library目錄是存放Apple自己開發的軟件。
   /Library目錄是系統管理員存放的第三方軟件。
   ~/Library/是用戶自己存放的第三方軟件。
  
步驟  
1. 首先創建一個自動任務的配置文件.plist,也可以從/System/Library/LaunchDaemons/獲取一個別的任務的plist文件,然后改改名字
  比如命名為com.apple.wind-auto.plist
2. plist里面設定編譯時間方式
  每小時啟動
  <key>StartInterval</key>
  <integer>60</integer>
  每天每小時0分啟動
 <key>StartCalendarInterval</key>
 <dict>
   <key>Minute</key>
   <integer>0</integer>
 </dict>
 每個周六的3點15分啟動
 <key>StartCalendarInterval</key>
 <dict>
   <key>Hour</key>
   <integer>3</integer>
   <key>Minute</key>
   <integer>15</integer>
   <key>Weekday</key>
   <integer>6</integer>
 </dict>
3. 拷貝到Libaray目錄下,例如:sudo cp /users/用戶/dev/iphone/project/com.apple.wind-auto.plist ./com.apple.wind-auto.plist
4. 啟動計划任務  sudo launchctl load -w /Library/LaunchDaemons/com.apple.wind-auto.plist
   停止計划任務  sudo launchctl unload -w /Library/LaunchDaemons/com.apple.wind-auto.plist

注意: -w是不寫入disk
 參考資料
 http://www.netingcn.com/mac-os-plist.html
 http://www.devdaily.com/mac-os-x/launchd-plist-examples-startinterval-startcalendarinterval
 http://www.devdaily.com/mac-os-x/mac-osx-startup-crontab-launchd-jobs


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM