nutch1.4定时爬取数据配合linux定时任务可以实现nutch的自动定时爬取,linux定时任务请参考《 Linux定时执行任务命令 :at和crontab》
步骤如下:
1、首先查看当前用户的 crontab服务执行命令:
crontab -l
执行结果:
no crontab for ***
表示没有定义 crontab 服务
2、编辑crontab服务:
crontab -e
*/10 * * * * /home/*/*.sh //每10分钟执行一次 ,*.sh中包含nutch抓取脚本如crawl
注意设置服务执行账户,此处设置为root如果是其他账户则需要对应修改为其他账户名。为*.sh文件设置可执行权限。
*.sh脚本中如果调用了系统环境变量则会发现脚步无法正常执行,原因是cron无法获取环境变量导致(相关说明文章:http://peigang.iteye.com/blog/1567706),改用如下写法:
crontab -e
*/10 * * * * . /etc/profile;/bin/sh /home/*/*.sh
. /etc/profile;/bin/sh 用来声明环境变量。
3、执行sudo apt-get install libnotify-bin
4、重新启动cron进程:
~#sudo /etc/init.d/cron restart
观察运行结果。重启可能不成功,使用如下步骤重新启动:
15:40:34^O^bin$ sudo /etc/init.d/cron stop
[sudo] password for sniffer:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service cron stop
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop cron
cron stop/waiting
15:40:49^O^bin$ ps -A | grep cron
15:40:54^O^bin$ sudo /etc/int.d/cron start
sudo: /etc/int.d/cron: command not found
15:41:11^O^bin$ sudo /etc/init.d/cron start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service cron start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start cron
cron start/running, process 14362
15:41:19^O^bin$ ps -A | grep cron
14362 ? 00:00:00 cron
注:nutch脚本存在无法找到JAVA_HOME的问题可以修改如下部分解决:
if [ "$JAVA_HOME" = "" ]; then
#echo "Error: JAVA_HOME is not set."
#exit 1
JAVA_HOME="***"
fi
分享到:
相关推荐
nutch1.4帮助文档,学习nutch1.4必备,最新nutch1.4核心类解读!
nutch 1.4 在windows下安装配置
nutch1.4 在windows下的安装配置环境搭建
nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据
Nutch是一个由Java实现的,刚刚诞生开放源代码(open-source)的web搜索引擎。Nutch目前最新的版本为version1.4。这个为nutch的最新版 1.4。
apache-nutch-1.4-bin.tar.gz.part2
Nutch分布式网络爬虫研究与优化.pdfNutch分布式网络爬虫研究与优化.pdfNutch分布式网络爬虫研究与优化.pdf
Nutch1[1].4_windows下eclipse配置图文详解
爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的工作流程包括以下几个关键步骤: URL收集: 爬虫从一个或多个初始URL开始,递归或迭代地发现新的URL,构建一个URL队列。这些URL...
Nutch:从搜索引擎到网络爬虫。中文。
apache-nutch-1.4-bin.part2
apache-nutch-1.4-bin.part1
基于Apache Nutch 1.8和Htmlunit组件,实现对于AJAX加载类型页面的完整页面内容抓取解析。 According to the implementation of Apache Nutch 1.8, we can't get dynamic ...
介绍 Nutch 的背景知识,包括 Nutch 架构,爬虫和...然后示例说明 Nutch 爬虫如何抓取目标网站内容,产生片断和索引,并将结果存放在集群的2个节点上。最后使用 Nutch 检索器提供的 API 开发应用,为用户提供搜索接口。
apache-nutch-1.4-bin.tar.gz.part1
Nutch1.0:Nutch1.0修改版(整合中文分词)原始码修改,编译打包
一个已经部署好的 nutch1.7爬虫。 导入到 eclipse里面就能用了。假如不能用的话。 还是装个cygwin 吧 找到org.apache.nutch.crawl.Crawl 这个类。 run configuration 在 Programa argument 里面 输入 crawl urls -...
网络编程一个非常不错的开源网络爬虫学习代码!
</p><p>Nutch诞生于2002年8月,是Apache旗下的一个用Java实现的开源搜索引擎项目,自Nutch1.2版本之后,Nutch已经从搜索引擎演化为网络爬虫,接着Nutch进一步演化为两大分支版本:1.X和2.X,这两大分支最大的区别...
Nutch 是一个开源Java 实现的搜索引擎。这里是它的安装包。