我想使用 crontab 运行包含 print("Hello World") 的 hello.py 文件。
为此,我的 hello.py 有以下代码:
#! /usr/bin/python3
print('Hello, world!')
而且,在同一个文件夹中,我使用 crontab -e 命令打开 crontab,为了每分钟执行一次这个文件,我写了:
1 * * * * ./hello.py
我还使用 chmod a+x hello.py 为文件设置了可执行权限。
当我跑
/usr/bin/python3 hello.py
它运行完美。此外,仅使用 ./hello.py,文件运行。
为什么使用 crontab 仍然没有执行?