Windows 上的 nohup 是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3382082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:30:36  来源:igfitidea点击:

What's the nohup on Windows?

windowsnohup

提问by www

I want to run a Java jar file like this:

我想像这样运行一个 Java jar 文件:

java -jar spider.jar

How to run it on the background on Windows?

如何在 Windows 的后台运行它?

Like this on Linux:

在 Linux 上是这样的:

nohup java -jar spider.jar > /var/tmp/spider.log 2>&1 &

采纳答案by Joey

On Windows it's not normal that a process terminates once its parent was killed (like Unix-likes do it normally). Therefore there is no direct necessity for something like nohup. If you want to avoid the console window associated with it, you can use javawbut redirection won't work, then.

在 Windows 上,进程在其父进程被杀死后终止是不正常的(就像类 Unix 系统通常会这样做)。因此,没有直接的必要性nohup。如果您想避免与其关联的控制台窗口,您可以使用javaw但重定向将不起作用。

回答by gutch

You could use the Windows startcommand:

您可以使用 Windowsstart命令:

start /min java -jar spider.jar

This command is not really the same as nohup; but it might be suitable if you're happy with the Java process running in a separate minimised window. See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx

这个命令实际上与nohup; 不同。但如果您对在单独的最小化窗口中运行的 Java 进程感到满意,它可能是合适的。请参阅http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx

回答by Lodewyk

The only way to get the nohup behavior, where the process still runs after logging off (like for micro-services, analytic tools, server batch jobs etc.), is to run the .bat file with the start javaw -jar ...contents as either a service or a scheduled task.

获得 nohup 行为的唯一方法,即注销后进程仍然运行(如微服务、分析工具、服务器批处理作业等),是运行 .bat 文件,将 start javaw -jar ...内容作为服务或预定任务。