简体   繁体   English

错误 1:在 crontab 中运行 cron 作业时不允许操作

[英]Errno 1: Operation not permitted while running cron job in crontab

I know this is a common error and it's been asked many times here on SO.我知道这是一个常见的错误,在 SO 上已经被问过很多次了。 I've been through all the solutions and none of them are working for me.我已经完成了所有的解决方案,但没有一个对我有用。

I'm using crontab on my iMac (running Catalina) to set up a cron job:我在 iMac(运行 Catalina)上使用 crontab 来设置 cron 作业:

42 11,20 * * * cd path/to/directory && echo <password> | sudo -S /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 filename.py >> log.txt

The full error I'm getting:我得到的完整错误:

Password:/Library/Frameworks/Python.framework/Versions/3.8/bin/python3: can't open file 'filename.py': [Errno 1] Operation not permitted

I've tried:我试过了:

  • Allowing Terminal to have Full Disk Access允许终端拥有完整的磁盘访问权限
  • Setting permissions on the files in the directory with sudo chown my-username:my-groupname filename使用 sudo chown my-username:my-groupname filename 设置目录中文件的权限
  • Adding password in the command在命令中添加密码

but this error never changes.但这个错误永远不会改变。

Any help gratefully accepted.任何帮助都感激地接受。

I was able to resolve this.我能够解决这个问题。 These are steps you can try to follow:这些是您可以尝试遵循的步骤:

  1. Open up System Preferences -> Security & Privacy (Mac OSX Catalina)打开系统偏好设置 -> 安全和隐私(Mac OSX Catalina)
  2. Open Privacy tab打开隐私选项卡
  3. Click Full Disk Access单击完全磁盘访问
  4. Ensure your version of python has been added to the list of application with access.确保您的 python 版本已添加到具有访问权限的应用程序列表中。

To do this, just find out where in your system Python is located, navigate there by pasting the path into Finder->Go->Go To Folder, finding the exe file, and dragging it into the Full Disk Access section of Privacy.为此,只需找出 Python 在您的系统中的位置,通过将路径粘贴到 Finder->Go->Go To Folder 中,找到 exe 文件,然后将其拖到 Privacy 的 Full Disk Access 部分来导航。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Crontab 无法执行 python 脚本,错误:“[Errno 1] Operation not allowed” - Crontab can't execute python script with error: “[Errno 1] Operation not permitted” OSError: [Errno 1] 不允许操作: - OSError: [Errno 1] Operation not permitted: OSError:[Errno 1]不允许操作 - OSError: [Errno 1] Operation not permitted Python3 Sockets - PermissionError: [Errno 1] Operation not allowed - 作为 root 运行 - Python3 Sockets - PermissionError: [Errno 1] Operation not permitted - running as root PermissionError:[Errno 1]写后读取时,Python中不允许进行此操作 - PermissionError: [Errno 1] Operation not permitted in Python while reading after write PermissionError: [Errno 1] 在 iPadOS 14 上使用 Pyto 时不允许操作 - PermissionError: [Errno 1] Operation not permitted while using Pyto on iPadOS 14 PermissionError: [Errno 1] docker conatiner 尝试连接到数据库时不允许操作 - PermissionError: [Errno 1] Operation not permitted while a docker conatiner tries to connect to database 权限错误:[Errno 1] 操作不允许 - Permission Error: [Errno 1] Operation Not permitted 覆盖范围 - PermissionError: [Errno 1] 不允许操作 - Coverage - PermissionError: [Errno 1] Operation not permitted Python 中的 Chmod - [Errno 1] 不允许操作 - Chmod in Python - [Errno 1] Operation not permitted
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM