I have one script.py which calls other multiprocessing scripts as follows my 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:
* * * * 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
it runs normally.
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:
def roda_processo(processo):
os.system('/usr/local/bin/python3.7 {}'.format(processo))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.