Scrapyd无法在启动时启动-Ubuntu 14 [英] Scrapyd not starting at boot-up - Ubuntu 14

查看:52
本文介绍了Scrapyd无法在启动时启动-Ubuntu 14的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上安装了 Scrapyd .

我希望它在我的服务器重新启动时启动.

I want it to start whenever my server restarts.

我在此处/etc/init/myjob.conf 中创建了具有以下内容的作业

I created job here /etc/init/myjob.conf with following contents

description     "my job"
start on startup
task
cd /var/www/scrapers &&  scrapyd >& /dev/null &

我还尝试将以下命令放入 crontab -e

I also tried to put following command in crontab -e

@reboot cd/var/www/scrapers&&刮擦>&/dev/null &

他们两个都不起作用.

我使用 grep CRON/var/log/syslog 检查了cronlog,在这里我看到命令已运行,但Scrapyd没有启动

I checked cronlogs using grep CRON /var/log/syslog and here I see command ran but Scrapyd did not start

Mar 30 13:33:28 mani CRON[446]: (root) CMD (cd /var/www/scrapers && scrapyd >& /dev/null &)

您可以看到该命令以ROOT用户身份运行.

As you can see that command ran as ROOT user.

如果我在终端中手动运行该命令,它将起作用!

If I manually run that command in terminal it works!

PS:

我将命令更改为

@reboot cd/var/www/scrapers&&刮擦>>/var/www/log.txt

日志文件已创建,但为空!

and log file is created but its empty!

推荐答案

我无法通过/etc/rc.local crontab 开始抓狂,所以我发现周围的工作.我敢肯定会有更好的方法,但就此而言,这对我有用.

I could not get my scrapyd start through /etc/rc.local or crontab so I found a work around. I am sure there will be a better way but for mean time this worked for me.

我创建了一个python文件 start.py .

I created a python file start.py.

import os

os.system('/usr/bin/python3 /home/ubuntu/.local/bin/scrapyd > /home/ubuntu/scrapy.log &')

只需通过crontab调用python文件 start.py .

And simply call the python file start.py through crontab.

通过 cronat -e 将其添加到crintab文件.

Add this to crintab file by cronat -e.

@reboot /usr/bin/python3 /home/ubuntu/start.py

基本上,我所做的是通过crontab调用python filr来通过外壳执行scrapy.

Basically what I did is execute the scrapy through shell by calling the python filr through crontab.

这篇关于Scrapyd无法在启动时启动-Ubuntu 14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆