mac 电脑定时开关机,定时执行作业


自动开关机在系统偏好设置-节能器-定时里
定时作业用launchctl  命令,参考  http://www.2cto.com/os/201305/215350.html

作业plist文件用plutil  命令进行检查

我是拷贝现成的plist文件,然后进行修改,然后用plutil  命令进行检查,最后用launchctl 命令进行 load unload


我的目录:

/Users/xxxxx/Library/LaunchAgents

<integer>300</integer>是说 5分钟运行一次 

<?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>info.springworks.xxx</string>
        <key>LimitLoadToSessionType</key>
        <string>Aqua</string>
        <key>ProgramArguments</key>
        <array>
          <string>/Users/xxxxx/xx.sh</string>
          <string>-runMode</string>
          <string>ifneeded</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>300</integer>
        <key>StandardErrorPath</key>
        <string>/Users/xxxxx/xxx.error.txt</string>
        <key>StandardOutPath</key>
        <string>/Users/xxxxx/xxx.out.txt</string>
</dict>
</plist>


你可能感兴趣的:(mac 电脑定时开关机,定时执行作业)