在groovy中,您可以像这样执行shell命令:
def process = "<some shell command>".execute()
println process.text()
但是,如果该命令是长时间运行的命令,我会发现它超时了。有办法防止这种情况发生吗?
我做了一些长时间运行的stufff(45分钟以上),在此过程中,我建立了一个cmdLine对象,该对象是要运行的命令行,然后:
def fose = new FileOutputStream(logFileErr)
def foss = new FileOutputStream(logFileStd)
Process proc = cmdLine.execute()
fose << proc.in
fose << proc.err
foss << proc.out
proc.waitFor()
现在已经为我工作了两年(到目前为止,我不必重新考虑此解决方案)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句