# Python elasticsearch-dsl bulk insert will not work as a cron job otherwise it works fine

**URL:** <https://discuss.elastic.co/t/python-elasticsearch-dsl-bulk-insert-will-not-work-as-a-cron-job-otherwise-it-works-fine/175722>\
**Category:** Elasticsearch\
**Created:** [April 7, 2019, 5:33pm UTC](https://discuss.elastic.co/t/python-elasticsearch-dsl-bulk-insert-will-not-work-as-a-cron-job-otherwise-it-works-fine/175722 "2019-04-07T17:33:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steelliberty](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@steelliberty](https://discuss.elastic.co/u/steelliberty)\
**Post date:** [April 7, 2019, 5:33pm UTC](https://discuss.elastic.co/t/python-elasticsearch-dsl-bulk-insert-will-not-work-as-a-cron-job-otherwise-it-works-fine/175722/1 "2019-04-07T17:33:32Z")

</div>

Hi --

I have an automated search and insert program based on elasticsearch-dsl.py and scrapy using the python elasticsearch pipeline for bulk insert into es.

It runs flawlessly when I start it as root, but when I try to run as cronjob, the scrapy section works but the bulk insert fails to insert with no error messages. I have tried numerous cron job ideas but to no avail. The entire process finishes but there is no actual data inserted.

I have been struggling with this for some time, does anyone have any ideas ? I tried [stackoverflow.com](http://stackoverflow.com) with no response.

Thank you

---

<div class="post-metadata">

**Author:** ![steelliberty](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@steelliberty](https://discuss.elastic.co/u/steelliberty)\
**Post date:** [April 7, 2019, 6:14pm UTC](https://discuss.elastic.co/t/python-elasticsearch-dsl-bulk-insert-will-not-work-as-a-cron-job-otherwise-it-works-fine/175722/2 "2019-04-07T18:14:51Z")

</div>

Ok .. I figured it out -- I was using absolute paths to the python scripts but failed to remember that cron jobs are started in the home directory, so there was not path to the settings file. a simple cd /home/midir && ./mypython.py worked ..

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 5, 2019, 6:15pm UTC](https://discuss.elastic.co/t/python-elasticsearch-dsl-bulk-insert-will-not-work-as-a-cron-job-otherwise-it-works-fine/175722/3 "2019-05-05T18:15:00Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
