【发布时间】:2021-04-30 10:09:23
【问题描述】:
我有以下要完成的任务列表,它们正在成功运行。
0 0 */1 * * bash /home/user/Code/agapov/start_GHR_Y00011285.sh >> ~/cron.log 2>&1
5 0 */1 * * bash /home/user/Code/agapov/start_GHR_Y00011280.sh >> ~/cron.log 2>&1
10 0 */1 * * bash /home/user/Code/agapov/start_GHR_Y10001320.sh >> ~/cron.log 2>&1
20 0 */1 * * bash /home/user/Code/agapov/aggregation.sh >> ~/cron.log 2>&1
25 0 */1 * * bash /home/user/Code/ivanov/start_API_N00001010.sh >> ~/cron.log 2>&1
文件结构如下:
#!/bin/bash
source /home/user/anaconda3/bin/activate
python /home/user/Code/agapov/GHR_Y00011280.py
conda deactivate
但随后出现问题,我添加了几个新文件以执行,但它们不起作用。这是此类文件的代码示例
#!/bin/bash
source /home/user/anaconda3/bin/activate
python /home/user/Code/analyzator.py
conda deactivate
正如你所看到的,它完全相似,python 文件本身启动并完美地完成了它的工作,但是牙冠出了点问题
Cron 日志:
/home/user/Code/start_analyzator.sh: line 4: conda: command not found
/home/user/Code/start_analyzator.sh: line 2: /home/user/anaconda3/bin/activate
: No such file or directory
/home/user/Code/start_analyzator.sh: line 3: python: command not found
bash: /home/user/Code/ivanov/start_DS_N00001400.sh: No such file or directory
/home/user/Code/start_analyzator.sh: line 4: conda: command not found
/home/user/Code/start_analyzator.sh: line 2: /home/user/anaconda3/bin/activate
: No such file or directory
/home/user/Code/start_analyzator.sh: line 3: python: command not found
/home/user/Code/start_analyzator.sh: line 4: conda: command not found
analyzator - 向电报发送消息的文件,这里是用于检查的设置
*/5 * * * * bash /home/user/Code/start_analyzator.sh >> ~/cron.log 2>&1
可能是什么问题,有些文件可以正常工作,有些则不能???
【问题讨论】:
-
看来您需要在 cron 作业中设置 PATH 变量。
-
您是否在 Windows 机器上创建了 shell 脚本?
-
@RamanSailopal 一切都已配置好,之前没有出现此类问题,旧设置成功。好像不是这样的
-
@tink 是的,我通过运行 Windows 10 的计算机 Moba 工作
-
将文件转换为unix行尾...