如何在预定时间运行 applescript

How to run applescript at scheduled time

如何在预定的时间 运行 我的 apple 脚本。我希望它每 45 分钟 运行,但我不知道该怎么做。我将我的苹果脚本保存为应用程序。接下来我该做什么?

谢谢

(目前我使用的是on idle函数,请问有更好的方法吗?)

有两种方法:

  • 在 Calendar.app 中创建一个触发脚本的循环事件
  • 在 ~/Library/LaunchAgents 中使用键 StartInterval2700
  • 创建启动代理

两种方式都可以处理标准编译脚本(.scpt 或 .scptd)

按计划查看 this launchd tutorial 运行 AppleScript。

我会使用 osascript 命令设置 crontab 到 运行 脚本。例如,参见 https://betterprogramming.pub/https-medium-com-ratik96-scheduling-jobs-with-crontab-on-macos-add5a8b26c30

因为 crontab 以小时和分钟为单位设置时间,我会将 Apple Script 设置为每 15 分钟 运行 并检查第一行是否是开始正文的正确时间脚本。