【发布时间】:2020-02-16 21:27:44
【问题描述】:
我试图让 cron 运行一个 python 文件,但它似乎没有运行。 cron中的命令是:
24 21 * * * python /mnt/c/Users/saifl/git/StaffTrainingLog/automate.py
日志中出现以下内容:
Feb 16 21:24:01 MSI CRON[3839]: (slatifi) CMD (python /mnt/c/Users/saifl/git/StaffTrainingLog/automate.py)
但是,它实际上并不运行代码。当我在上面的备份中运行命令时,它可以正常工作。请指教。
更新(罗密欧回应后):
我现在已将命令移至脚本 (automate_script):
#!/bin/bash
source ~/.bashrc
cd /mnt/c/Users/saifl/git/StaffTrainingLog
/usr/bin/python3 automate.py
我现在在 Crontab 中有以下内容:
50 14 * * * /mnt/c/Users/saifl/git/StaffTrainingLog/automate_script
当在命令行中运行 /mnt/c/Users/saifl/git/StaffTrainingLog/automate_script 时,它可以工作,但是,它确实使用 cron 运行,因为它出现在日志中,但没有任何反应。
【问题讨论】:
标签: cron windows-subsystem-for-linux