python - Cannot change directory to a script using bash - cron -
this question has answer here:
i have script runs multiple instances of python scrapy crawlers, crawlers int /root/crawler/batchscript.py
and in /root/crawler/ have scrapy crawler.
crawlers working fine.
batchscript.py looks this, (posting relevent code)
from scrapy.settings import settings scrapy.utils.project import get_project_settings amazon_crawler.spiders.amazon_scraper import myspider process = crawlerprocess(get_project_settings()) when run batchscrip.py inside /root/crawler/ directory scraper runs fine.
but when run outside of directory using python /root/crawler/batchscript.py not run intended, (settings not imported correctly), get_project_settings() empty.
i have tried creating bash script too create bash script called batchinit.sh
#!/bin/bash alias batchscript="cd /root/crawler/" python batchscript.py and behaviour same :(
when run
batchinit.shinside/root/crawler/directory scraper runs fine.but when run outside of directory using
bash /root/crawler/batchinit.shnot run intended, (settings not imported correctly),get_project_settings()empty.
why doing it? ultimate goal?
i want create cronjob script. tried schedule cronjobs using above mentioned commands have issues mentioned above.
using bash, do:
cd /root/crawler && python batchscript.py it's policy use absolute paths programs/executables referenced in cron jobs.
Comments
Post a Comment