mac下使用plist实现定时任务
记录下主要步骤:
- 新建一个任务脚本文件,如 /Users/username/Downloads/autoRun.sh (里面的具体内容就是到了时间要跑的任务内容)
- chmod 755 autoRun.sh (确保有可执行的权限)
- 然后进入到~/Library/LaunchAgents 下建一个plist文件,如com.twh.test.autorun.plist
- plist文件内容可以参考下面的:
- Label 可以随便起,但是要唯一 1 
 2
 3
 4ProgramArguments 存放需要定时跑的脚本路径+名字 
 StartCalendarInterval 可以定时到 “时 分 秒”
 也可以使用StartInterval 表示间隔多少秒,如
 StartInterval 60
6.
| 1 | 开始执行定时任务 launchctl load com.twh.test.autorun.plist | 
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
