开发者

What's the nohup on Windows?

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:

noh开发者_Go百科up java -jar spider.jar > /var/tmp/spider.log 2>&1 &


You could use the Windows start command:

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


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 javaw but redirection won't work, then.


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.


save the following code to nohup.vbs, and add the directory to PATH.

Set args=Wscript.Arguments
Set ws=CreateObject("wscript.shell")
ws.Run args(0),0,true

then, run:

nohup "java -jar spider.jar > /var/tmp/spider.log"

Note that you should quote the full commands and the redirects.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜