擅长:python、mysql、java
<p>当然,在crontab中运行Python脚本并没有什么错,但是会发生很多不好的事情,因为环境不是您所习惯的环境。你知道吗</p>
<p>键入交互式shell <code>python directory.py</code>时,路径和所有必需的PYTHON环境变量都已设置为登录和交互式shell初始化的一部分,默认情况下,当前目录是您的主目录或您当前所在的任何位置。你知道吗</p>
<p>当从crontab运行相同的命令时,不会指定当前目录(但可能不是您期望的目录),路径仅为<code>/bin:/usr/bin</code>,并且不会设置python环境变量。这意味着您必须调整crontab文件中的环境变量,直到获得正确的Python环境并设置当前目录。你知道吗</p>