我正在运行一个我想在它完成后重新运行的命令,而无需导航回终端再次输入该命令。
我知道在 Ubuntu 中,我可以使用命令运行终端,如果我设置正确,它将永远循环,例如 gnome-terminal -x $MY_COMMAND
.
鉴于我无法将 Powershell 标记为重新运行命令而不是关闭窗口,我如何无限期地重复命令?
最佳答案
这将在执行完成后无限重复运行命令:
While (1)
{
Start-Process -FilePath 'python3' -ArgumentList @('.\manage.py','runserver_plus','8080') -Wait -ErrorAction 'SilentlyContinue'
}
或者:
#requires -Version 3
While (1)
{
Try {
$Params = @{FilePath='python3'
ArgumentList=@('.\manage.py','runserver_plus','8080')
Wait=$True
ErrorAction='Stop'}
Start-Process @Params
} Catch {
<# Deal with errors #>
Continue
}
}
关于powershell - 如何在Powershell中永远重复一个命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46182207/