在 macOS 中使用 cron 定时任务和 Linux 下略有区别。
首先在终端输入,查看服务是否运行:
sudo launchctl list | grep cron
输出结果:
- 0 com.vix.cron
接下来查看启动项的配置:
locate com.vix.cron
如果提示 database 不存在
WARNING: The locate database /var/db/locate.database does not exist. To create the database, run the following command: sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist Please be aware that the database can take some time to generate; once the database has been created, this message will no longer appear.
按照上面的英文提示,创建一个 database,等几分钟后才会生成相关文件:
$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist $ locate com.vix.cron /System/Library/LaunchDaemons/com.vix.cron.plist
随后可以使用 crontab -e 创建任务,具体方法参考:https://javascript.net.cn/articles/690
修改时间 2024-05-12
声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。