Created
August 16, 2011 22:02
-
-
Save shauvik/6d701adedbfd85be74b0 to your computer and use it in GitHub Desktop.
Windows power shell run commands with timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$array = "folder1", "folder2" | |
cd c:\experiments | |
Foreach ($element in $array) {echo "Processing $element"; ` | |
$p = $(Start-Process java -ArgumentList "-jar script.jar $element" -RedirectStandardOutput $element\out.log -RedirectStandardError $element\err.log -PassThru);` | |
if ( ! $p.WaitForExit(1800000) ) | |
{ echo "$element did not exit after 30min"; $p.kill() } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment