Cannot change directory to a script using bash - cron
<p>I have a script that runs multiple instances of Python Scrapy crawlers, Crawlers are int <code>/root/crawler/batchscript.py</code></p>

<p>and in <code>/root/crawler/</code> I have that scrapy crawler.</p>

<p>Crawlers are working perfectly fine.</p>

<p>batchscript.py looks like this, (posting only relevent code)</p>

<pre><code>from scrapy.settings import Settings
from scrapy.utils.project import get_project_settings
from amazon_crawler.spiders.amazon_scraper import MySpider

process = CrawlerProcess(get_project_settings())
</code></pre>

<p>When I run <code>batchscrip.py</code> inside <code>/root/crawler/</code> directory scraper runs fine.</p>

<p>But when I run it from outside of this directory using <code>python /root/crawler/batchscript.py</code> then it does not run as intended, (Settings are not imported correctly), <code>get_project_settings()</code> are empty.</p>

<p><strong>I have tried creating a BASH script too</strong>
I create bash script called <code>batchinit.sh</code></p>

<pre><code>#!/bin/bash
alias batchscript="cd /root/crawler/"
python batchscript.py
</code></pre>

<p>and behaviour is same :( </p>

<blockquote>
  <p>When I run <code>batchinit.sh</code> inside <code>/root/crawler/</code> directory scraper
  runs fine.</p>
  
  <p>But when I run it from outside of this directory using <code>bash 
  /root/crawler/batchinit.sh</code> then it does not run as intended,
  (Settings are not imported correctly), <code>get_project_settings()</code> are
  empty.</p>
</blockquote>

<p><strong>Why I am doing it? What is ultimate goal?</strong></p>

<p>I want to create a cronjob for this script. I tried to schedule cronjobs using above mentioned commands but I have issues as mentioned above.</p>