无法使用/usr/local/bin的Shebang运行Python脚本

发布于 2025-01-22 23:12:13 字数 614 浏览 3 评论 0原文

我有一个python脚本保存到/usr/local/bin的

#!/usr/bin/python3

顶部,并且在重新启动后30秒内运行它,并且无法正常运行。 When I try to run ./usr/local/bin/check_bios.py I get

bash: ./usr/local/bin/check_bios.py: No such file or directory

When I copy it to my home directory it works fine. When I execute it with

python /usr/bin/local/check_bios.py

it runs fine.我

alias python="python3"

在BashRC文件中有,但我不认为这是导致这种行为的原因。我尝试在我的路径中添加/usr/bin/local添加/bin/local,但是Cron不会尽我所能想到的路径。有人知道为什么Cron作业不会执行并whay。如果有帮助,我在Linux Mint 20.2上。

I have a python script saved to /usr/local/bin with

#!/usr/bin/python3

at the top and a chron job to run it 30 seconds after reboot and it's not working. When I try to run ./usr/local/bin/check_bios.py I get

bash: ./usr/local/bin/check_bios.py: No such file or directory

When I copy it to my home directory it works fine. When I execute it with

python /usr/bin/local/check_bios.py

it runs fine. I have

alias python="python3"

in my bashrc file, but I don't think that is what's causing this behavior. I tried adding /usr/bin/local to my path, but cron wouldn't use the path as far as I can think of. Does anyone know why the cron job won't execute and whay ./usr/bin/local/check_bios.py would throw an error? I'm on Linux Mint 20.2 if that helps at all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺渁∝ 2025-01-29 23:12:13

从错误中:

bash: ./usr/local/bin/check_bios.py: No such file or directory

cron作业正在寻找./ usr/local/bin/bin路径中的check_bios.py脚本。

由此,我猜想克朗的工作是:

? ? ? ? ? ./usr/local/bin/check_bios.py

在哪里?代表时间值(故意将它们留作?既然它们在帖子中没有提及,也没有与问题有关)。

我相信应该是:

? ? ? ? ? . /usr/local/bin/check_bios.py

From the error:

bash: ./usr/local/bin/check_bios.py: No such file or directory

the cron job was looking for the check_bios.py script in the ./usr/local/bin path.

From that, I guessed that the cron job was:

? ? ? ? ? ./usr/local/bin/check_bios.py

where ? represents the time values (deliberately left them as ? since they weren't mentioned in the post, nor are they relevant to the issue).

I believe it should be:

? ? ? ? ? . /usr/local/bin/check_bios.py
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文