-1

I had this .sh file:

#!/bin/bash
cd /home/leenga/Desktop/crawlCron
scrapy crawl quotes

and here is my crontab:

*/2 * * * * /usr/bin/bash /home/leenga/Desktop/crawlCron/crawlcommand.sh >> /home/leenga/Desktop/crawlCron.out

Why it doesn't working? Help me!

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Anna
  • 1
  • 1

1 Answers1

0

cron sets up a different environment from your own shell, so, in all likelihood the problem is simply that cron does not have path information to find scrapy. You can fix the cron environment using the information in this post, but the most straightforward way to get around the problem is to use the fully qualified path information when invoking scrapy from cron - for example, use /opt/local/bin/scrapy in your shell script.

Eljuan
  • 84
  • 8
  • Thank you, but when I add the fully qualified path information when invoking scrapy from cron in my shell script, It said that "/home/leenga/anaconda2/lib/python2.7/site-packages/scrapy: Is a directory " – Anna Jul 31 '17 at 03:34
  • That sounds like a package location & not a script. From your shell, type `which scrapy` and use that path in your script. Alternatively you can try running the earlier version of your script from crontab by prepending `. $HOME/.profile; ` after the scheduling symbols to your cron job, as in `*/20 * * * * $HOME/.profile; /home/leenga/Desktop/crawlCron/crawlcommand.sh >> /home/leenga/Desktop/crawlCron.out` – Eljuan Aug 01 '17 at 04:23