简体   繁体   English

运行Anaconda-Scrapy作为Cron作业

[英]Run Anaconda-Scrapy as Cron job

I am trying to run a scrapy (installed with anaconda2) crawler as a cron job. 我正在尝试运行crapy(安装有anaconda2)爬虫作为cron作业。 No luck so far. 到目前为止没有运气。

Here is cron command: 这是cron命令:

* * * * * sh /home/username/anaconda2/folder/getdata.sh

The cron runs every 1 min ( I checked the log file, it seem to be ok) And here is the code inside the sh file: cron每1分钟运行一次(我检查了日志文件,似乎还可以),这是sh文件中的代码:

#!/home/username/anaconda2/bin/python
cd /home/username/anaconda2/crawler_folder
PATH=$PATH:/home/username/anaconda2/bin
export PATH
scrapy crawl spider

The sh code executes as expected in the terminal but not as a cron job. sh代码在终端中按预期执行,但不作为cron作业执行。 Can you please help 你能帮忙吗

This worked for me as the .sh file and the cron job was unchanged. 这对我有用,因为.sh文件和cron作业没有更改。

#!/home/username/anaconda2/bin/bash
PATH=/home/username/anaconda2/bin:home/username/anaconda2/sbin
cd /home/username/anaconda2/crawler_folder && scrapy crawl spider

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM