[英]Executing python script with cron job from MacOS
I am trying to create a very simple Cron job on MacOS to execute a Python script.我正在尝试在 MacOS 上创建一个非常简单的 Cron 作业来执行 Python 脚本。
My Cron job :我的 Cron 工作:
* * * * * usr/bin/python3 /Users/gaetan/Desktop/createfolder.py
When I run the script from the terminal is working fine but from cron is not doing anything.当我从终端运行脚本时工作正常,但从 cron 没有做任何事情。
I don't understand what could be the error, I have given all the rights and double check the path.我不明白可能是什么错误,我已授予所有权限并仔细检查路径。
on Mac and linux, the crontab syntax is same!在 Mac 和 linux 上,crontab 语法是相同的! But i suggest not to manipulate your crontab with default system for some reason.但我建议不要出于某种原因使用默认系统操作您的 crontab。
As you are using python
You can use celery
It will save your huge time schedule task: https://docs.celeryproject.org/en/stable/userguide/periodic-tasks.html当您使用python
您可以使用celery
它将节省您大量的时间安排任务: https : //docs.celeryproject.org/en/stable/userguide/periodic-tasks.html
You can absolutely use cron
on macOS.你绝对可以在 macOS 上使用cron
。 First step grant the binary permissions over your full disk.第一步授予对整个磁盘的二进制权限。
Second, be sure you check for a full path to everything - your python executable is not correct in the question as it needs to start with /usr/...
其次,确保您检查所有内容的完整路径 - 您的 python 可执行文件在问题中不正确,因为它需要以/usr/...
Here is an answer on a partner site specific to Apple operating systems with details on debugging and privacy controls if you'd like more help.如果您需要更多帮助,这里是特定于 Apple 操作系统的合作伙伴网站上的答案,其中包含有关调试和隐私控制的详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.