windows nohup
时间: 2023-08-27 15:16:22 浏览: 375
Windows操作系统中没有内置的nohup命令,但是可以通过其他方式实现类似的功能。你可以使用PowerShell来实现类似nohup命令的功能,具体步骤如下:
1. 打开PowerShell终端。
2. 输入以下命令,将命令执行到后台并保持运行,即使终端关闭:
```shell
Start-Process -NoNewWindow -FilePath <command> -ArgumentList "<arguments>" -RedirectStandardOutput "<output_file_path>" -RedirectStandardError "<error_file_path>"
```
注意替换`<command>`为需要执行的命令,`<arguments>`为命令的参数,`<output_file_path>`和`<error_file_path>`为输出和错误日志的保存路径。
举个例子,如果你想在后台运行`python script.py`命令,并将输出保存到`output.log`文件中,可以使用以下命令:
```shell
Start-Process -NoNewWindow -FilePath python -ArgumentList "script.py" -RedirectStandardOutput "output.log" -RedirectStandardError "error.log"
```
这样,你可以关闭PowerShell终端而不会中断命令的执行。输出和错误信息将保存在指定的日志文件中。
希望这个方法对你有所帮助!如果有任何问题,请随时提问。
阅读全文
相关推荐


















