What is the equivalent of 'nohup' in PowerShell?

梦想与她 提交于 2020-12-01 11:06:40

问题


How can I emulate the behavior of the unix command nohup in PowerShell? That is nohup my-other-nonblocking-command. I have noticed the Start-Job command, however the syntax is somewhat unclear to me.


回答1:


> Start-Job my.exe

Fails with this output:

Start-Job : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Start-Job my.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Start-Job], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.StartJobCommand

Try this instead:

> Start-Job { & C:\Full\Path\To\my.exe }

It will work, and you will see output like this:

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
2      Job2            BackgroundJob   Running       True            localhost             & .\my.exe

I hope that is what you're looking for because your question is a bit vague.



来源:https://stackoverflow.com/questions/19321903/what-is-the-equivalent-of-nohup-in-powershell

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