1

这是我的脚本:(test2.sh)

#!/bin/sh
echo try1 > run1.txt
cd /home/folder1/folder2
echo try2 > run2.txt
scrapy crawl somepage > /root/sans1.txt
echo try3 > run3.txt

这是我的 cron 文件:

00 * * * * cd /root && sh test2.sh >> /root/diggi.log

所有文件 run1.txt、run2.txt、run3.txt 和 sans1.txt 都已创建.....我得到了 run1、2、3 的正确输出,但 scrapy 命令似乎没有像我得到的那样工作sans1.txt 作为一个空文件

4

1 回答 1

4

首先你需要做chmod u+x test2.sh

还包括在安装了您的scrapy的.sh文件路径中

#!/bin/sh
PATH=$PATH:/usr/local/bin
export PATH
scrapy crawl somepage > /root/sans1.txt

然后尝试 crontab

00 * * * * cd /root && test2.sh >> /root/diggi.log
于 2013-06-22T15:19:47.150 回答