在ubuntu后台运行时,crawler停止

2024-09-26 22:50:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python做了一个简单的爬虫,它有无限循环,所以不能停止。 随机延迟17~30,这个爬虫抓取同一个页面,找到定期更新的href链接并存储到Mysql。 我用的是Ubuntu服务器。 因为我用Linux命令

$ nohup python crawer.py & 

所以这个爬虫程序是在Ubuntu服务器后台运行的。 我想已经跑了4个小时了。 但突然,爬虫停了下来。 第二天我再试一次。而且效果很好! 有什么问题?这是关于网页的块吗?或者nohup命令有时间限制???? 谢谢。你知道吗


Tags: py命令程序服务器链接ubuntulinuxmysql
1条回答
网友
1楼 · 发布于 2024-09-26 22:50:52

不,nohup会做它设计的目的。即:

 The nohup utility invokes utility with its arguments and at this time
 sets the signal SIGHUP to be ignored.  If the standard output is a termi-
 nal, the standard output is appended to the file nohup.out in the current
 directory.  If standard error is a terminal, it is directed to the same
 place as the standard output.

 Some shells may provide a builtin nohup command which is similar or iden-
 tical to this utility.  Consult the builtin(1) manual page.

Bash(和其他shell)&将作为任务的背景。nohup with&;有效地让进程在后台运行,即使您终止tty/pty会话。你知道吗

我相信问题是你的Python程序崩溃了。你应该花些时间在一些日志记录上,并找出答案。e、 克:

nohup my_app.py &> myapp.log &

相关问题 更多 >

    热门问题