What's the nohup on Windows?

匿名 (未验证) 提交于 2019-12-03 03:06:01

问题:

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 & 

回答1:

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.



回答2:

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



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!