简体   繁体   English

从cron调用的scrapy脚本仅调用了构造函数

[英]scrapy script called from cron only constructor called

scrapy crawler is called through a shell script, which is used as the command line in a crontab entry. scrapy搜寻器是通过Shell脚本调用的,该脚本在crontab条目中用作命令行。 The shell script looks like: Shell脚本如下所示:

scrapy crawl targethost.com 抓取抓取targethost.com

when time is due and it did execute, but seems only the constructor is called (I verified with debug output). 时间到了,它确实执行了,但是似乎只调用了构造函数(我用调试输出验证了)。 The problem is solved by re-write the shell script as: 通过将shell脚本重新编写为:

scrapy crawl targethost.com &> cronlog.log 抓取抓取targethost.com&> cronlog.log

I just don't know why. 我只是不知道为什么。

Scrapy executes correctly, but doesn't output all its messages to STDOUT, so the simple pipe ( > ) doesn't redirect everything into your file, only that stuff that goes to STDOUT (which as you say, seems to be the constructor only). Scrapy可以正确执行,但是不会将其所有消息输出到STDOUT,因此简单的管道( > )不会将所有内容重定向到您的文件中,而只是将那些内容发送到STDOUT(正如您所说的,它似乎只是构造函数) )。

With &> it fetches all messages from scrapy and puts them into your log. 使用&>可以从scrapy中获取所有消息,并将它们放入您的日志中。

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

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