Windows 上的 nohup 是什么?
我想运行这样的Java jar文件:
java -jar spider.jar
How to run it on the back on Windows?
在 Linux 上就像这样:
nohup java -jar spider.jar > /var/tmp/spider.log 2>&1 &
I want to run a Java jar file like this:
java -jar spider.jar
How to run it on the background on Windows?
Like this on Linux:
nohup java -jar spider.jar > /var/tmp/spider.log 2>&1 &
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用 Windows
start
命令:该命令与
nohup
并不相同;但如果您对在单独的最小化窗口中运行的 Java 进程感到满意,那么它可能是合适的。请参阅 http://www.microsoft。 com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspxYou could use the Windows
start
command: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在 Windows 上,一旦父进程被杀死,进程就会终止,这是不正常的(就像类 Unix 系统通常会这样做一样)。因此,没有直接必要像
nohup
这样的东西。如果您想避免与之关联的控制台窗口,可以使用 javaw,但重定向将不起作用。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 usejavaw
but redirection won't work, then.获得 nohup 行为(进程在注销后仍然运行(例如微服务、分析工具、服务器批处理作业等))的唯一方法是使用
start javaw -jar 运行 .bat 文件...
内容作为服务或计划任务。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.vbs
中,并将该目录添加到 PATH 中。然后,运行:
请注意,您应该引用完整的命令和重定向。
save the following code to
nohup.vbs
, and add the directory to PATH.then, run:
Note that you should quote the full commands and the redirects.
对于 Windows,请在命令提示符或终端中运行以下提到的命令
nohup (文件需要运行) > (您需要保存日志的文件)2>&1
例如:
nohup ./bin/windows/kafka-server-start.bat config/server.properties > ./MyKafka.log 2>&1
For windows run following mentioned command in Command Prompt or in Terminal
nohup (file need to run) > (File you need to save the log) 2>&1
Ex:
nohup ./bin/windows/kafka-server-start.bat config/server.properties > ./MyKafka.log 2>&1