我正在设置一个 launchctl 服务器来定期运行一个 Python 文件。所以我编写了一个.plist 文件和 auto.sh 文件,并且它正常工作。但是,当我安装了 macOS Catalina 后,它失败了。我在 auto.sh 中写入了 "ls -l" 命令来检查文件权限,日志显示:
ls: .: Operation not permitted
python3: can't open file 'auto.py': [Errno 1] Operation not permitted
我该如何修复它?非常感谢。
这是我的代码:
auto.sh:
#!/bin/bash
. ~/.bash_profile
conda activate base
cd /Users/gassy/Documents/
ls -l
python3 auto.py
我将这个.plist文件放置在/Users/gassy/Library/LaunchAgents/com.gassy.fangzhou.plist。
...
<key>Program</key>
<string>/Users/gassy/auto/launch.sh</string>
...