nohup vs screen-长时间运行会更好吗? [英] nohup vs screen -- which is better for long running process?

查看:202
本文介绍了nohup vs screen-长时间运行会更好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我运行了一个长时间运行的脚本,该脚本对数据库模式进行了更改,该更改具有要在迁移后检查的输出.我想将此写入文件.

Background: I have a long running script that makes database schema changes that has output I would want to check after the migration. I would want to write this to a file.

我一直在阅读有关nohup和屏幕的堆栈溢出.我已经尝试过两者,并且对两者都有担忧.

I have been reading stack overflow about nohup and screen. I have tried both and have concerns about both.

IN:如何将进程作为背景运行而永不死?

他们说他们使用了nohup,腻子杀死了该过程.这怎么可能?我无法使用Mac OS X终端进行复制.

They said they used nohup and putty killed the process. How is this possible? I have been unable to replicate using Mac OS X terminal.

对于screen,我很害怕键入exit而不是ctrl + a,d

With screen I am terrified of typing exit instead of ctrl + a, d

另外,如果我只是在使用屏幕时退出终端应用程序,那似乎可以保留状态.

Also If I just quit the terminal app when using screen, it seems to preserve the state.

屏幕似乎是更好的解决方案,因为如何打开其中的许多屏幕并切换回状态确实很不错.

Screen seems to be the better solution because it is really nifty how you can have a bunch of them open and switch back to the state.

在我的情况下,您会推荐什么?我没有再运行脚本一个月左右的时间(发布版本时).我是否应该对屏幕感到更舒服并且坚持下去?

What would you recommend in my situation? I don't have the run the script for another month or so (When I have a release). Should I become more comfortable with screen and just stick with that?

推荐答案

两个都有自己的+和-:

Both have there own + and - :

nohup:

  1. nohup非常适合在不使用proc的情况下在后台运行proc 需要任何用户输入(例如httpd服务器)或任何其他服务器proc(例如) 那.
  2. nohup不会在proc执行的目录中创建日志.日志文件名 默认值为nohup.out
  3. 避免proc因错误而被杀死 ctrl + C,ctrl + D.只是一个安全的守卫.
  4. 通常默认情况下使用基本设置进行安装.无需像屏幕一样单独安装.
  5. 该功能非常特定于在后台运行作业 和转储输出.低内存密集型.
  1. nohup is good to use for running procs in background when proc don't need any user input like httpd server or any other server proc like that.
  2. nohup does create log in dir of proc execution. log file name default is nohup.out
  3. It avoids proc getting killed due to mistaken ctrl+C , ctrl+D . Just a safe guard.
  4. It's normally installed by default with basic setup. No need to install separately like screen.
  5. It's functionality is very specific to running a job in background and dumping output. Low memory intensive.

屏幕:

  1. 可以单独安装.您不能去数据中心或登录
    任何框,并期望屏幕存在.
  2. 可以很好地管理不同主题上的多个终端,并为其命名.
  3. 它更多地是终端管理器,而不是像nohup这样的无限时间运行proc的命令.
  4. 如果proc需要用户输入,则更合适.像安装
    脚本,是/否提示.
  5. 具有特色的色调,带来了记忆.但同意,某些功能确实很棒.
  1. Got to install separately. You can NOT go to a data center or login to
    any box and expect screen is present.
  2. Good to manage multiple terminals on separate subjects and give them name.
  3. Its more of terminal manager and not a command to run a proc for infinite time like nohup.
  4. It's more suitable if proc need user input. Like install
    scripts, yes/no prompts.
  5. With tones of features, comes it's memory. But agreed, some are really great features.

总而言之,两者都是在不同的议程上做出的两个不同的事情,因此很难进行比较.

To conclude, both are two different things made with different agendas so comparison is difficult.

干杯!

这篇关于nohup vs screen-长时间运行会更好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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