[英]python multithreading issue in cronjob no execute
I have one script.py which calls other multiprocessing scripts as follows my scripts.py:我有一个 script.py,它按照我的 scripts.py 调用其他多处理脚本:
import os
from multiprocessing import Pool
scriptspy = [
'/pyscripts/apoiont01.py',
'/pyscripts/access.py',
'/pyscripts/dental.py',
'/pyscripts/cremers.py',
'/pyscripts/delcuritib.py',
'/pyscripts/dtalndes.py',
'/pyscripts/lobo.py',
'/pyscripts/ierre.py',
'/pyscripts/daster.py',
'/pyscripts/dsul.py',
'/pyscripts/doema.py',
'/pyscripts/maz.py',
'/pyscripts/deura.py',
'/pyscripts/der.py',
'/pyscripts/dlo.py',
'/pyscripts/deoltda.py',
'/pyscripts/dpeed.py',
'/pyscripts/derr.py',
'/pyscripts/dweb.py',
]
def roda_processo(processo):
os.system('python3.7 {}'.format(processo))
for s in scriptspy:
roda_processo(s)
My crontab -e:我的 crontab -e:
* * * * 1,5 /usr/local/bin/python3.7 /pyscripts/scripts.py > /pyscripts/logs/scripts.log
Funny thing is, if I run that same manual run command on the terminal: / usr / local / bin / python3. 7 /pyscripts/scripts.py > / pyscripts/logs / scripts.log
有趣的是,如果我在终端上运行相同的手动运行命令:
/ usr / local / bin / python3. 7 /pyscripts/scripts.py > / pyscripts/logs / scripts.log
/ usr / local / bin / python3. 7 /pyscripts/scripts.py > / pyscripts/logs / scripts.log
it runs normally. / usr / local / bin / python3. 7 /pyscripts/scripts.py > / pyscripts/logs / scripts.log
运行正常。
Log /var/log/cron.log: https://gist.githubusercontent.com/braganetx/a05c8b7257df79305dd1b79008323011/raw/8aec453a74566e8872608d1705f05004c1e12e5e/log登录/var/log/cron.log: https://gist.githubusercontent.com/braganetx/a05c8b7257df79305dd1b79008323011/raw/8aec453a74566e8872608d1705f05004c1e12e5e/log
You should replace this with the version with the full path to the python interpreter, because whatever is run from the cron
lacks the "usual" environment variables setup, namely, PATH is what you're missing the most:您应该将其替换为带有 Python 解释器完整路径的版本,因为从
cron
运行的任何内容都缺少“通常的”环境变量设置,即 PATH 是您最缺少的:
def roda_processo(processo):
os.system('/usr/local/bin/python3.7 {}'.format(processo))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.